本來想更新npm為淘寶源,執行了一下代碼:
npm install -g cnpm --registry=https://registry.npm.taobao.org
可是報錯如下:
npm install -g npm
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'internal/fs'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/username/.npm/_logs/2017-08-04T09_24_59_677Z-debug.log
嘗試改變模塊權限:
sudo chmod -R 777 /usr/local/lib/node_modules/
依然無效,在網上找了很多辦法,最后的解決辦法是:
試盡各種辦法,最后還是手動卸載了再重裝了npm
1、sudo npm uninstall npm -g
如果步驟1卸不掉npm了(我就是這種情況)
2、進到npm的安裝目錄 /usr/local/lib/node_modules/npm/
sudo make uninstall
3、手動重裝npm
curl -L[https://npmjs.com/install.sh](https://npmjs.com/install.sh)| sh
4.查看npm版本
npm -v