module.js:471 throw err; ^ Error: Cannot find module '../lib/utils/unsupported.js' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) 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 (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12)
The error in the original post is from running npm run build. I want to see the error from npm install
Please do the following: rm -rf node_modules npm install provide the contents of that error message
Thanks.
文章建議移除全部套件後再重裝 以前也有不少次經驗是移除後再裝,就能恢復正常了 XD 那就試看看吧:
$ sudo rm -rf /usr/local/lib/node_modules/ $ npm install -bash: /usr/local/bin/npm: No such file or directory
結果變成找不到 npm 了 @@
Reinstall npm again
再重裝一次試看看
$ brew install npm Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). No changes to formulae.
Warning: node 8.5.0 is already installed, it's just not linked. You can use `brew link node` to link this version.
系統說已經有 npm 了,但連結不到!?
Link node
可能是什麼參照沒有設定好,照 command line 中的提示打打看。
$ brew link node
Linking /usr/local/Cellar/node/8.5.0... Error: Could not symlink share/doc/node/lldb_commands.py Target /usr/local/share/doc/node/lldb_commands.py already exists. You may want to remove it: rm '/usr/local/share/doc/node/lldb_commands.py'
To force the link and overwrite all conflicting files: brew link --overwrite node
To list all files that would be deleted: brew link --overwrite --dry-run node
系統提示說 conflicts 了,直接用最新的覆寫舊的應該 OK 吧
$ brew link --overwrite node
Linking /usr/local/Cellar/node/8.5.0... Error: Could not symlink share/doc/node/gdbinit /usr/local/share/doc/node is not writable.
權限不足無法覆寫,只好改一下檔案權限再試一次
$ sudo rm '/usr/local/share/doc/node/gdbinit' $ sudo chown -R $USER /usr/local $ brew link --overwrite node $ npm -bash: /usr/local/bin/npm: No such file or directory
沒用 😿
brew doctor
查到 brew 有指令能修復,試試看
$ brew doctor $ brew prune $ npm -bash: /usr/local/bin/npm: No such file or directory
沒用x2 😿😿
Reinstall npm again 2
用另一種方式裝 npm 看看
$ curl -L http://npmjs.org/install.sh | sudo sh $ npm > -bash: /usr/local/bin/npm: No such file or directory
Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.
Error: Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system.