When I try to run the app.js
file created by express, I get the following error:
$ node app.js
node.js:134
throw e; // process.nextTick
Install express
npm install -g express
Create a new app
express your_app
cd into app directory
cd your_app
use npm link to resolve modules
npm link express
What about NODE_PATH=/usr/local/lib/node_modules
in .bashrc or .bash_profile? I think it's the real correct way.
Set NODE_PATH=NODE_HOME\node_modules
.
I'm using windows 7 and it works fine.
Finally with Linux a good way to do is to use the command : sudo apt-get install node-express
But with express 4 we must use express-generator to make app skeleton, install it with 'npm install express-generator -g', and then run 'express myapp' command. see also install express
For all problems with express with a mac computer:
The solution is:
chown
to your user the .npm folder :
sudo chown -R Webmaste /Users/webmaste/.npm/
At your test folder or your folder:
sudo npm install -g express@2.5.8
Invoke express from your actual location:
/usr/local/share/npm/bin/express
sudo cd . && npm install
Finally:
node app
the final message in the console should look like this:
Express server listening on port 3000 in development mode
Use local installs for require(), and global installs for command-line apps.
If you need both, use the npm link
command.