Nodejs framework express application how to make a JavaScript node

flag language

Nodejs framework express application how to make a JavaScript node

Creating and developing modern applications or websites is associated with the knowledge of tools belonging to the JavaScript ecosystem. The basis is knowledge of node.js (nodejs, node), i.e. the heart of the JavaScript ecosystem. How to install node.js?

Use my advice: .

Once you have nodejs installed, it's time for the next stages of building an express and nodejs blog.

Open (in Windows as an administrator) CMD, i.e. the so-called Command Prompt. Go to the directory where you want to install the blog express application.

Installing Express.js The Express.js package is available in two versions:

express-generator - NPM package - global, containing a command line tool for quickly creating applications (skeleton)

express - module package - local, placed in the node_modules folder of the Node.js application.

First install globally (with the –g parameter) express-generator:

$ npm install express-generator -g

Using the express-generator, we create an express application skeleton called dgexpress:

$ express --view=pug dgexpress

The parameter: --view = pug is optional, but using it may facilitate future work with the nodejs and express applications. I will explain this in the next part of the guide.

Change to the dgexpress directory - CMD command:

cd dgexpress

Type in CMD:

set DEBUG = myapp: * & npm start

At: https: // localhost: 3000 / you can run the express application skeleton. For now, it is quite modest, it only contains the inscription:

Express Welcome to Express

You can check the correctness of the global express installation by typing on the command line:

express –version

The effect should be to print the express version. The lack of the returned express version, probably associated with the lack of the appropriate path to express in Windows (Path), e.g. in Windows 10:


Welcome to Express tutorial tutorial

Local Express installation

We create a directory in which we want to place the Express application:

Express will create a package.json file with npm init

$ mkdir expresslocal $ cd expresslocal

For the express application, using the npm init command, we will create a package.json file with the index.js entry point:

$ npm init

With the Enter key accept the individual questions of the json file installer, look at the picture.

Express npm JavaScript nodejs

The next step is to install Express in the expresslocal catalog:

$ npm install express –save

The above command will install Express and the necessary dependencies in the directory: node_modules.

Express.js node.js additional modules

By installing Express.js we can also use additional modules, e.g. Stylus engine. In this way we will receive the already configured application:

$ express -c style express

According to the instructions displayed on the CMD terminal, enter: Dependency installation:

$ cd expressstyl && npm install

Launching the application

$ SET DEBUG = express style: * & npm start

The result of the express style application is again:

Express Welcome to Express

This is how the basic structure of the Express application was created, along with the necessary dependencies. You can start building a real Express application, all you need is HTML5, CSS3, JavaScript, jQuery, AJAX, JSON, Jade and / or Handlebars and databases, e.g. MongoDB.

Good luck building an Express-based application. I invite you to my next guides. See in the side menu similar tips to: nodejs framework express application how to make a JavaScript node.


See in the menu similar articles to: Application nodejs framework express how to make a JavaScript node


szkolenia bezpłatne kolejne lekcje
kursy, porady, artykuły znajdziesz w Menu Tematycznym