[英]express not found - `-bash: express: command not found`
I'm using this tutorial to install express so was running: 我正在使用本教程安装Express,因此正在运行:
$ sudo npm install -g express
it passed successfully: 它成功通过了:
Password:
express@4.13.4 /usr/local/lib/node_modules/express
├── escape-html@1.0.3
├── content-type@1.0.1
├── cookie-signature@1.0.6
├── methods@1.1.2
├── vary@1.0.1
├── parseurl@1.3.1
├── etag@1.7.0
├── path-to-regexp@0.1.7
├── content-disposition@0.5.1
├── serve-static@1.10.2
├── range-parser@1.0.3
├── utils-merge@1.0.0
├── array-flatten@1.1.1
├── fresh@0.3.0
├── merge-descriptors@1.0.1
├── cookie@0.1.5
├── depd@1.1.0
├── qs@4.0.0
├── on-finished@2.3.0 (ee-first@1.1.1)
├── debug@2.2.0 (ms@0.7.1)
├── finalhandler@0.4.1 (unpipe@1.0.0)
├── proxy-addr@1.0.10 (forwarded@0.1.0, ipaddr.js@1.0.5)
├── type-is@1.6.12 (media-typer@0.3.0, mime-types@2.1.10)
├── send@0.13.1 (destroy@1.0.4, ms@0.7.1, statuses@1.2.1, mime@1.3.4, http-errors@1.3.1)
└── accepts@1.2.13 (negotiator@0.5.3, mime-types@2.1.10
but when I try to run as the tutorial says: 但是当我尝试按照教程中所述运行时:
$ express donuts
I get: 我得到:
-bash: express: command not found
am i missing something? 我想念什么吗?
To create a express application skeleton, Express
provides a command line tool ( express-generator
: application generator tool) and using this you can create a application skeleton to quickly. 要创建Express应用程序框架,
Express
提供了命令行工具( express-generator
:应用程序生成器工具),使用该工具可以快速创建应用程序框架。
Install express-generator
with the following command: 使用以下命令安装
express-generator
:
$ sudo npm install express-generator -g
And after a successful installation check installed version using the following command: 在成功安装之后,请使用以下命令检查已安装的版本:
$ express -V
To see the available command options use the -h option: 要查看可用的命令选项,请使用-h选项:
$ express --help
Usage: express [options] [dir]
Options:
-h, --help output usage information
-V, --version output the version number
-e, --ejs add ejs engine support (defaults to jade)
--hbs add handlebars engine support
-H, --hogan add hogan.js engine support
-c, --css <engine> add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css)
--git add .gitignore
-f, --force force on non-empty directory
And the following creates an Express app named myapp in the current working directory: 然后以下代码在当前工作目录中创建一个名为myapp的Express应用程序:
$ express myapp
create : myapp
create : myapp/package.json
create : myapp/app.js
create : myapp/public
create : myapp/public/javascripts
create : myapp/public/images
create : myapp/routes
create : myapp/routes/index.js
create : myapp/routes/users.js
create : myapp/public/stylesheets
create : myapp/public/stylesheets/style.css
create : myapp/views
create : myapp/views/index.jade
create : myapp/views/layout.jade
create : myapp/views/error.jade
create : myapp/bin
create : myapp/bin/www
To install dependencies run the following command: 要安装依赖项,请运行以下命令:
$ npm install
In your case you have installed the express framework globally not express application generator tool. 在您的情况下,您已全局安装了Express框架而不是Express应用程序生成器工具。
For more reference see the following link - http://expressjs.com/en/starter/generator.html 有关更多参考,请参见以下链接-http://expressjs.com/en/starter/generator.html
Hope this will help you !! 希望这个能对您有所帮助 !!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.