Fork me on GitHub

ubuntu 安装 npm、nodejs 各种问题

nodejs let notifier = require('update-notifier')({pkg}) 报错

先卸载nodejs,然后安装稳定最新版

# apt-get remove nodejs   //删除nodejs  
# curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - //nodejs源  
# apt-get update //更新包  
# apt-get install nodejs //安装nodejs  
# npm install npm -g //更新npm  

Cannot find module 'are-we-there-yet'

1) Go to the global node_modules directory (what would npm root -g print if you could run it):

$ cd /usr/local/lib/node_modules
2) Remove the broken npm directory or move it somewhere else (note that you might need to elevate permissions for this and the following steps):

$ mv npm /tmp
3) Download and unpack fresh npm from the registry (substitute version you want to install, e.g. 3.10.8):

$ curl -L registry.npmjs.com/npm/-/npm-{VERSION}.tgz | tar xz --transform="s:^package:npm:"
You can automate some of that with this install script:

$ curl -L https://www.npmjs.com/install.sh | sh

参考

posted @ 2018-09-19 22:46  削微寒  阅读(2885)  评论(0编辑  收藏  举报