2016-04-23 47 views
0

我使用這個tutorial安裝快車所以正在運行:快遞不到found` -bash:快遞:命令不found`

$ sudo npm install -g express

順利通過:

Password: 
[email protected] /usr/local/lib/node_modules/express 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] ([email protected]) 
├── [email protected] ([email protected]) 
├── [email protected] ([email protected]) 
├── [email protected] ([email protected], [email protected]) 
├── [email protected] ([email protected], [email protected]) 
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected]) 
└── [email protected] ([email protected], [email protected] 

但是當我嘗試按照教程所述運行時:

$ express donuts

我得到:

-bash: express: command not found

我這麼想嗎?

+0

express不會出現在$ PATH變量中。使用'export PATH = $ PATH:/ path/to/express /'將其位置導出到'PATH' varailbe – selyunin

回答

1

要創建快速應用程序框架,Express提供了一個命令行工具(express-generator:應用程序生成器工具),並使用它可以快速創建應用程序框架。

用下面的命令來安裝express-generator

$ sudo npm install express-generator -g 

,並使用以下命令成功安裝檢查安裝的版本後:

$ express -V 

要查看可用的命令選項使用-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 

而且下面創建一個E名爲隨心應用MYAPP在當前工作目錄:

$ 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 

要安裝依賴運行以下命令:

$ npm install 

在你的情況,你已經安裝了快車框架全球無法表達應用程序生成器工具。

更多信息參見以下鏈接 - http://expressjs.com/en/starter/generator.html

希望這將幫助你!