NPM 异常

执行 NPM 出现以下错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
internal/modules/cjs/loader.js:550
throw err;
^

Error: Cannot find module '../lib/utils/unsupported.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.Module._load (internal/modules/cjs/loader.js:475:25)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:92:3)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)

解决:

1、卸载 NODE 
    brew uninstall --force node

2、删除 node_modules 目录:
    sudo rm -rf /usr/local/lib/node_modules/
    
3、安装 n node 版本管理
    brew install n
    
4、安装 node 版本
    n ls //查看 node 版本列表
    n <version>