I'm new with nodejs and trying to learn it. I have installed node framework express as global module by command:
$ sudo npm install express -g
This works correctly and I have it in /usr/lib/node_modules
. Then I'm creating a new project on express:
$ express app
But this doesn't create project folder and does not return any error code, clear node code works fine. Anybody knows how to detect and fix this error?
As of Ubuntu 16.04 LTS, the problem occurs when express is installed globally. To fix this, make sure you install express to your working directory even if you have installed globally. Use
sudo npm i express-generator --save
to save it to your working directory in every project you do.
Had this problem and fixed it easily, without having to reinstall nodejs or any other dependency.
For me the solution was simply to install the nodejs-legacy package:
Perhaps a
sudo express app
might do the trick? (I see you're executing in/var/www
, which generally is off limits from regular users?)First thing to try is if the plugin is installed:
$ npm -g ls | grep express
If nothing is returned, try reinstalling it.
Since in this case it was still installed, the next solution was to reinstall Node entirely.
There is a great post on cleaning up Node installations here: Uninstall Node.JS using Linux command line?
found it. the npm package is actually named express-generator
you can then use
that results in :
Cheers ! Olivier
Source : http://expressjs.com/guide.html#executable
This is what I did to get mine to work and make sure everything was working ok on Ubuntu 12.04 running Node 0.8.21 and Express 3.2.0.
First install express
Now check that express is working by querying it for the version:
Now I went and created an express app:
The following was output:
So, following the instructions it gave me, I ran the following two commands in sequence:
After just a minute it finished and I was able to open /urs/lib/node_modules/app.js and work with it. Also, running node app like it said in the instructions during the express module creation worked as well.
From a previous comment, it looks like you might have fixed it by reinstalling node, but I still hope this will help you.