Ubuntu 安裝 nodeJS npm, 解決 /usr/bin/env: ‘node’: Too many levels of symbolic links

一般安裝nodeJS, npm不會有什麼問題。

只是我安裝的情況,NPM會產生以下問題:

用sudo apt-get install npm之後,

鍵入npm --version會告知以下錯誤:
/usr/bin/env: ‘node’: Too many levels of symbolic links

如果在此時繼續安裝NODE-RED基本上也都是失敗的
(安裝指令:sudo npm install -g --unsafe-perm node-red)

所以還是不得不解決這個問題阿QQ

解決方法:

簡單說就是把在/usr/local/bin/node的連結重新建立

先刪除node:
sudo rm /usr/local/bin/node

重新建立node:
sudo ln -s "$(which nodejs)" /usr/local/bin/node


截錄參考網頁的解釋:
You need to symlink the nodejs executable to node sudo ln -s "$(which nodejs)" /usr/local/bin/node The reason for this is that when you do "apt-get install node", it installs an unrelated package, so they had to choose a different name so it wouldn't conflict

參考 reference:

https://stackoverflow.com/questions/30281057/node-forever-usr-bin-env-node-no-such-file-or-directory

留言

熱門文章