我正在关注需要我快速安装的MEAN堆栈教程:
我跑了这个:
npm install -g express-generator
这是我的结果:
username@username-Inspiron-3521:~$ npm install -g express-generator
/home/username/npm/bin/express -> /home/username/npm/lib/node_modules/express-generator/bin/express
express-generator@4.13.1 /home/username/npm/lib/node_modules/express-generator
├── sorted-object@1.0.0
├── mkdirp@0.5.1 (minimist@0.0.8)
└── commander@2.7.1 (graceful-readlink@1.0.1)
但是当我做的时候
express --ejs flapper-news
The program 'express' is currently not installed. You can install it by typing:
sudo apt-get install node-express
我做错了什么?
感谢您的时间。
修改
当我做npm install
username@username-Inspiron-3521:~/Documents/mean/flapper_news$ npm install
npm ERR! install Couldn't read dependencies
npm ERR! Linux 3.16.0-51-generic
npm ERR! argv "/home/username/local/bin/node" "/home/username/local/bin/npm" "install"
npm ERR! node v4.2.1
npm ERR! npm v2.14.7
npm ERR! path /home/username/Documents/mean/flapper_news/package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno -2
npm ERR! syscall open
npm ERR! package.json ENOENT: no such file or directory, open '/home/username/Documents/mean/flapper_news/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.
npm ERR! Please include the following file with any support request:
npm ERR! /home/username/Documents/mean/flapper_news/npm-debug.log
EDIT2
运行npm install -g express
并输入express -v
后,我得到了这个:
bash: /usr/bin/express: No such file or directory
EDIT3
这是我的.bashrc
文件:
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
export PATH=$HOME/local/bin:$PATH
export NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript:/home/username/npm/lib/node_modules
export PATH=/home/username/Android/Sdk/platform-tools:$PATH
export PATH=/home/username/Android/Sdk/tools:$PATH
答案 0 :(得分:5)
从npm install -g express generator
/home/username/npm/bin/express -> /home/username/npm/lib/node_modules/express-generator/bin/express
您的npm正在您的主目录中安装全局模块,它将二进制链接放在/home/username/npm/bin
目录中,因此您需要将其添加到您的路径中。将其添加到您的.bashrc
:
export PATH=$HOME/npm/bin:$PATH
答案 1 :(得分:0)
请原谅我一个明显的问题,但我必须确定 - 你是否在包含package.json文件的目录中运行$ npm install
?使用express --ejs flapper-news
创建应用后,您应该在cd flapper-news
之前npm install
,是吗?