Express application generator
Use the application generator tool, express-generator
, to quickly create an application skeleton.
You can run the application generator with the npx
command (available in Node.js 8.2.0).
For earlier Node versions, install the application generator as a global npm package and
then launch it:
Display the command options with the -h
option:
For example, the following creates an Express app named myapp. The app will be created in a folder named myapp in the current working directory and the view engine will be set to Pug:
Then install dependencies:
On MacOS or Linux, run the app with this command:
On Windows Command Prompt, use this command:
On Windows PowerShell, use this command:
Then, load http://localhost:3000/
in your browser to access the app.
The generated app has the following directory structure:
- app.js
Directorybin
- www
Directorypackage.json
Directorypublic
- images
- javascripts
Directorystylesheets
- style.css
Directoryroutes
- index.js
- users.js
Directoryviews
- error.pug
- index.pug
- layout.pug