nodejs, npm works fine before. When I try to upgrade it
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
And type npm -v
, it throw "Segmentation fault"
. I restart system and I type a same command again, again it show same error. So I remove nodejs and npm package from ubuntu 14.04 through ubuntu Software Center and reinstall it again.
Then I try to install the phonegap through npm package using a command
sudo npm install -g phonegap
But it doesn't return any progress. So I check the npm version, it throws an error "Segmentation fault". I also try sudo npm -v
. It return nothing.
So I decide to remove the npm from ubuntu 14.04 using the command
sudo apt-get remove npm
Then I type sudo npm install -g phonegap
it can't throw npm package is not available.
My Question is:
- The package is not there, then why i type
npm -v
, it return "Segmenatation Fault" - If package not remove, then when i type
sudo npm install -g phonegap
, why It cannot install phonegap.
Help me to solve this issue. Or provide a way to unistall nodejs, npm, phonegap, expressjs, less clean way and reinstall it.
Edit:
Edit1:
As per @chj1axr0 answer, the script throw an error after nodejs install
Best Answer
I have googled around and it seems (for some) that there is a bug in the latest Ubuntu software version of Nodejs that causes the segmentation fault that you are haveing
The best way to install it is by getting node from the source and compiling it.
I have setup a simple script on a Github gist that will take care of it.
Make sure and use
sudo chmod a+x /path/to/file/install_nodejs_latest.sh
to make sure it will start. Then usesudo sh /path/to/file/install_nodejs_latest.sh
to start it. (It must me ran with sudo for all the commands to fire correctly)The script removes the old nodejs, npm and all node modules.
It will update npm at the end of the script.
Every once and awhile it is recommended to do
sudo npm install -g npm
(If you want the latest) because npm upgrades faster then node js doesafter the script is complete run
npm -v
andnode -v
If the versions pop up then runsudo npm install -g phonegap
,sudo npm install -g cordova
,sudo npm install -g less
also if you want to update any of the modules in the future all you have to do is install it again and that will override the preveous one. expressjs is for an app by app bases so it's not recomended to install it globally