Express is a popular framework for building and running Node.js applications.
Install the Express Generator#
You can create a new Express application using the Express Generator tool. The Express Generator is shipped as an npm module and installed by using the npm command-line tool npm.
sudo npm install -g express-generator
The -g switch installs the Express Generator globally on your machine so you can run it from anywhere.
Create a New Application
You can now create a new Express application called myExpressApp by running:
express myExpressApp --view pug
The --view pug parameters tell the generator to use the pug template engine (formerly known as jade).
To install all of the application's dependencies, go to the new folder and run npm install.
cd myExpressApp
npm install
Run the Application
Last, let's ensure that the application runs. From the terminal, start the application using the npm start command to start the server.
npm start
The Express app by default runs on http://localhost:3000.
You can create a new Express application using the Express Generator tool. The Express Generator is shipped as an npm module and installed by using the npm command-line tool npm.
sudo npm install -g express-generator
The -g switch installs the Express Generator globally on your machine so you can run it from anywhere.
Create a New Application
You can now create a new Express application called myExpressApp by running:
express myExpressApp --view pug
The --view pug parameters tell the generator to use the pug template engine (formerly known as jade).
To install all of the application's dependencies, go to the new folder and run npm install.
cd myExpressApp
npm install
Run the Application
Last, let's ensure that the application runs. From the terminal, start the application using the npm start command to start the server.
npm start
The Express app by default runs on http://localhost:3000.
Comments
Post a Comment