Search code examples
node.jsnpmsegmentation-fault

After upgrading Node, 'Segmentation fault (core dumped)' error shows up. How can I fix it?


I was trying to upgrade Node by following the instruction from https://tecadmin.net/upgrade-nodejs-via-npm/. I did sudo npm cache clean -f, sudo npm install -g n, and sudo n stable. After the above commands, I stupidly did sudo ln -sf /usr/local/n/versions/node/11.8.0/bin/node /usr/bin/node. After this command, I checked the /usr/local/n/versions/node folder. It had 10.15.3, so I typed sudo ln -sf /usr/local/n/versions/node/10.15.3/bin/node /usr/bin/node.

Right now, node -v gives me 10.15.3. However, npm -version gives me Segmentation fault (core dumped). Other commands like npm update -g also gives me the same error message.

Other posts about the Segmentation fault (core dumped) error don't seem to be directly related to my problem.

How can I fix this?

I am using Ubuntu 19.04.

Thank you.


Solution

  • I faced The same Issue just now, This because of conflicting the npm of node and nodejs

    so remove nodejs by below commands

    sudo apt-get remove nodejs
    

    this will remove all nodejs related Packages,

    after above command you have to run autoremove command just like that

    sudo apt autoremove
    

    this will solve the problem,

    Now you just have node pacakge in your machine, and NPM (segmentation dumped) error will also resolves.

    you can more dig about What is segmentation fault