Cannot find module '../lib/utils/unsupported.js'
运行npm run clean出错:
internal/modules/cjs/loader.js:596 throw err; ^ Error: Cannot find module '../lib/utils/unsupported.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15) at Function.Module._load (internal/modules/cjs/loader.js:520:25) at Module.require (internal/modules/cjs/loader.js:650:17) at require (internal/modules/cjs/helpers.js:20: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:153:3) at Module._compile (internal/modules/cjs/loader.js:702:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10) at Module.load (internal/modules/cjs/loader.js:612:32) at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
解决办法:
sudo rm -rf /usr/local/lib/node_modules/npm
先把之前的文件删除
userdeMBP:~ user$ brew uninstall --force node Error: Refusing to uninstall /usr/local/Cellar/node/11.1.0 because it is required by yarn, which is currently installed. You can override this and force removal with: brew uninstall --ignore-dependencies node
然后再删除node,因为我有安装yarn,所以使用--ignore-dependencies:
userdeMBP:~ user$ brew uninstall --ignore-dependencies node Uninstalling /usr/local/Cellar/node/11.1.0... (3,936 files, 47.0MB) node 9.10.1 is still installed. Remove all versions with `brew uninstall --force node
然后再安装:
userdeMacBook-Pro:~ user$ brew install node ==> Downloading https://homebrew.bintray.com/bottles/node-11.1.0.mojave.bottle.t Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/2d71518883b6f6ce458778abea35981525ecdee4a14408431b9f42ed132015e1--node-11.1.0.mojave.bottle.tar.gz ==> Pouring node-11.1.0.mojave.bottle.tar.gz ==> Caveats Bash completion has been installed to: /usr/local/etc/bash_completion.d ==> Summary 🍺 /usr/local/Cellar/node/11.1.0: 3,936 files, 47.0MB
然后就成功了:
userdeMacBook-Pro:~ user$ npm Usage: npm <command> where <command> is one of: ...