← 返回命令列表

Linux command

express 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Create Express app with generator

npx express-generator [myapp]

Create with view engine

npx express-generator --view=[pug] [myapp]

Create with CSS preprocessor

npx express-generator --css=[sass] [myapp]

Create without view engine

npx express-generator --no-view [myapp]

Create with git ignore

npx express-generator --git [myapp]

说明

express-generator scaffolds Express.js web applications. It creates the basic directory structure, package.json, and boilerplate code for starting an Express server. Express is a minimal Node.js web framework. The generator provides a conventional starting point with routes, views (optional), static files, and error handling.

参数

--view _engine_
View engine: pug, ejs, hbs, hjs, twig.
--css _engine_
CSS preprocessor: sass, less, stylus, compass.
-e, --ejs
Use EJS template engine.
--pug
Use Pug template engine.
--hbs
Use Handlebars template engine.
--no-view
Generate without view engine.
-c _engine_
CSS engine (same as --css).
--git
Add .gitignore.
-f, --force
Force on non-empty directory.

FAQ

What is the express command used for?

express-generator scaffolds Express.js web applications. It creates the basic directory structure, package.json, and boilerplate code for starting an Express server. Express is a minimal Node.js web framework. The generator provides a conventional starting point with routes, views (optional), static files, and error handling.

How do I run a basic express example?

Run `npx express-generator [myapp]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --view _engine_ do in express?

View engine: pug, ejs, hbs, hjs, twig.