我在Ubuntu 16.04上安装了最新版本的node(6.0.0),但当我试图在全局范围内安装Yeoman(或任何其他npm模块)时,它抛出了一个分段错误
~$ node -v
6.0.0
~$ npm -v
3.8.6
~$ sudo npm install -g yo
normalizeTree → headers ▌ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
Segmentation fault (core dumped)
~$ sudo npm install -g npm
normalizeTree → 200 ▌ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
Segmentation fault (core dumped)
我也尝试过通过克隆git存储库来重新安装npm,但在中也失败了
~/Documents$ git clone https://github.com/npm/npm.git
Cloning into 'npm'...
remote: Counting objects: 55706, done.
remote: Compressing objects: 100% (158/158), done.
remote: Total 55706 (delta 64), reused 0 (delta 0), pack-reused 55547
Receiving objects: 100% (55706/55706), 29.55 MiB | 1.25 MiB/s, done.
Resolving deltas: 100% (30297/30297), done.
Checking connectivity... done.
~/Documents$ ls
npm
~/Documents$ cd npm
~/Documents/npm$ ls
AUTHORS changelogs CONTRIBUTING.md lib Makefile README.md
bin cli.js doc LICENSE node_modules scripts
CHANGELOG.md configure html make.bat package.json test
~/Documents/npm$ ./configure node_debug=1
~/Documents/npm$ make
scripts/doc-build.sh doc/cli/npm-bugs.md man/man1/npm-bugs.1
make[1]: Entering directory '/home/cameron/Documents/npm'
node cli.js install marked-man --no-global
normalizeTree → install ▌ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
Makefile:151: recipe for target 'node_modules/.bin/marked-man' failed
make[1]: *** [node_modules/.bin/marked-man] Segmentation fault (core dumped)
make[1]: Leaving directory '/home/cameron/Documents/npm'
Makefile:96: recipe for target 'man/man1/npm-bugs.1' failed
make: *** [man/man1/npm-bugs.1] Error 2
~/Documents/npm$
我搜索了Stack Overflow以找到答案,但没有任何帮助。我不知道现在该尝试什么。有什么建议吗?
对于升级到ubuntu 19.04后面临此问题的其他人,请尝试运行:
sudo apt --auto-remove purge npm
sudo apt --auto-remove purge nodejs
升级时似乎必须安装多个版本的nodejs或npm。运行以上命令后,您可以检查nodejs和npm的版本。
此修复程序已发布在npm社区:
https://npm.community/t/segmentation-fault-core-dumped-error-for-every-npm-command/7086
我的第一个建议是在npm回购中打开一个问题,但截至本文撰写之时,它已经打开了2269个问题。。。我的天。
我建议用nodeenv安装一个旧版本的node,我目前使用它,效果很好,事实上,对我来说,这是使用node.js的方法,我不喜欢受到向后兼容性破坏的影响。
重新安装一个新的nodejs版本,使用n.
n vx.x.x
n rm vx.x.x (remove broken verison)