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

14,724

Solution 1

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

Solution 2

Try to run npm rebuild to recompile your dependencies.

Share:
14,724
Jeong Kim
Author by

Jeong Kim

Updated on June 17, 2022

Comments

  • Jeong Kim
    Jeong Kim almost 2 years

    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.

  • Adarsh Sharma
    Adarsh Sharma about 5 years
    I'm glad I could help.
  • Yusuf
    Yusuf almost 4 years
    it removed all nodejs, npm, node for me. So had to install again
  • Monkey D. Luffy
    Monkey D. Luffy over 3 years
    Not working for me, can you help me a little bit here?
  • taper
    taper over 3 years
    This works for me when my npm pack command failed. However, it does removes all npm related packages installed by apt-get but since I manage npm using conda, this isn't an issue for me.
  • LIU Qingyuan
    LIU Qingyuan about 3 years
    This must be the funniest error I can encounter in a released version of a famous software... Every execution of npm, with or without any options, yields segfault immediately, and it is resolved after remove all nodejs related packages as described in this answer.
  • Jack Steam
    Jack Steam about 2 years
    Using pnpm, pnpm rebuild worked perfectly!