3

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
Johhan Santana
  • 2,336
  • 5
  • 33
  • 61
  • just do `npm install -g express` too. ref here http://stackoverflow.com/questions/23367534/what-is-the-different-between-express-and-express-generator – Aishwat Singh Oct 30 '15 at 21:34
  • @aishwatsingh that's not required for this.. the express generator has very little to do with express. All it does is install an app that uses express, express will get installed on the next step. – Kevin B Oct 30 '15 at 21:36
  • According the npm doc of the module, you have to install dependencies with $ npm install. Have you try that ? – TGrif Oct 30 '15 at 21:43
  • @KevinB the `npm install -g express-generator` gets installed successfully but after that, it is suppose to install express automatically which it doesn't or it does but the path to it is wrong, I'm really not sure what's wrong here. – Johhan Santana Oct 30 '15 at 21:46
  • @TGrif I've edited the question after I ran `npm install` – Johhan Santana Oct 30 '15 at 21:48
  • @aishwatsingh after running your command I get an error, I've edited the question with the error message. – Johhan Santana Oct 30 '15 at 21:51
  • error says u don't have a package.json file ENOPACKAGEJSON and ya have u tried dat like `sudo npm install -g express` and try express -V – Aishwat Singh Oct 30 '15 at 21:56
  • #edit2 express is a nodejs module, you can get version with npm express -v – TGrif Oct 30 '15 at 22:00
  • @TGrif then how do I use it? If I run `express --ejs flapper-news` it doesn't recognize express. – Johhan Santana Oct 31 '15 at 23:47
  • what flavor is linux are you running? – Sgnl Nov 01 '15 at 02:49
  • @Sgnl I have Elementary OS Freya Ubuntu 14.04 – Johhan Santana Nov 01 '15 at 15:36
  • worth a shot...run sudo in front of these commands and try again. – deek Nov 03 '15 at 08:31

2 Answers2

5

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
piemonkey
  • 741
  • 3
  • 6
  • I ended up re-installing everything and made sure this path worked, now everything seems to be working except that generator-karma which is a pain to fix but it belongs in another question, thanks! – Johhan Santana Nov 03 '15 at 14:04
0

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?

Piotr Jaworski
  • 584
  • 1
  • 5
  • 20
  • 1
    I'm pretty sure I did, but anyhow, I ended up re-installing node with npm and everything else and made sure my paths where correct as the answer by @piemonkey . Thanks! – Johhan Santana Nov 03 '15 at 14:05