node.js - npm 在 Ubuntu 16.04 和 Node 6.0.0 上抛出段错误

标签 node.js ubuntu npm segmentation-fault

我已经在 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

关于node.js - npm 在 Ubuntu 16.04 和 Node 6.0.0 上抛出段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36961871/

相关文章:

node.js - 使用 BlueMix 的 Node-RED 编辑器和 MQTT->调试 Node 时出现意外字符串

node.js - 让 REACT 应用程序在端口 3001 上运行以显示在 AWS EC2 Http 端口 80 上

typescript - vue-gtag 错误 : "maximum call stack size exceeded"

Ubuntu - Acronis True Image 的替代品

javascript - 使用 Browserify 构建 npm - 错误 : Cannot find module

javascript - 错误代码 ELIFECYCLE,npm start 不起作用

javascript - useFakeTimers 和异步回调

javascript - 避免在履行 promise 时显示某个元素

javascript - 我应该在兑现 promise 之前还是之后更新缓存?

ruby-on-rails - 使用 Upstart 启动 Sidekiq