npm install express-generator not installing express

故事扮演 提交于 2019-12-07 21:35:36

问题


I'm following a MEAN stack tutorial that requires me to have express installed:

I run this:

npm install -g express-generator

and this is my results:

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)

but when I do

express --ejs flapper-news

The program 'express' is currently not installed. You can install it by typing:
sudo apt-get install node-express

what am I doing wrong?

Thanks for the time.

edit

When i do 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

after running npm install -g express and typing express -v I get this:

bash: /usr/bin/express: No such file or directory

edit3

This is my .bashrc file:

### 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

回答1:


Looking at this line from your output for npm install -g express generator

/home/username/npm/bin/express -> /home/username/npm/lib/node_modules/express-generator/bin/express

Your npm is installing global modules within your home directory and it's placing binary links in the /home/username/npm/bin directory, so you'll need to add this to your path. Add this to your .bashrc:

export PATH=$HOME/npm/bin:$PATH



回答2:


Excuse me for an obvious question, but I have to be sure - do you run $ npm install in the directory that contains the package.json file? After you create the app with express --ejs flapper-news, you are supposed to cd flapper-news before npm install, did you?



来源:https://stackoverflow.com/questions/33445007/npm-install-express-generator-not-installing-express

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!