優雅地亂玩Linux-3-Ubuntu下NodeJS的安裝

來源:互聯網
上載者:User

標籤:radio   use   conflict   script   binary   hive   arch   json   http   

文章最初發表於szhshp的第三邊境研究所
轉載請註明

Ubuntu 16.04 安裝NodeJS

天哪Linux安裝NodeJS居然也這麼麻煩

NodeJS安裝
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -sudo apt-get install -y nodejs

可能會出現找不到 curl的錯誤, apt-get一下curl就可以了

NPM安裝
curl http://npmjs.org/install.sh | sudo shsudo apt-get install curl
node VS nodeJS?

NPM, Node安裝成功後執行:

node -v

發現報錯

-bash: /usr/sbin/node: No such file or directory

但是可以使用

nodejs -v

這個問題的原因:

There is a naming conflict with the node package (Amateur Packet Radio Node Program), and the nodejs binary has been renamed from node to nodejs. You‘ll need to symlink /usr/bin/node to /usr/bin/nodejs or you could uninstall the Amateur Packet Radio Node Program to avoid that conflict.

當然直接用nodejs命令也可以執行node程式, 不過後續如果安裝modules就會出現node 未定義的錯誤

解決方案是添加一個link:

You need to manually create a symlink /usr/bin/node. Shortcut for bash compatible shells:

sudo ln -s `which nodejs` /usr/bin/node

Or if you use non-standard shells, just hardcode the path you find with which nodejs:

sudo ln -s /usr/bin/nodejs /usr/bin/node
NPM: Permission Denied

npm安裝Hexo出現問題:

node scripts/build_highlight_alias.js > highlight_alias.jsonsh: 1: cannot create highlight_alias.json: Permission denied

換成sudo依然報錯.

解決方案見官方Guide: https://docs.npmjs.com/getting-started/fixing-npm-permissions

參考文獻
  • https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
  • http://www.cnblogs.com/seanlv/archive/2011/09/24/2189719.html
  • https://stackoverflow.com/questions/18130164/nodejs-vs-node-on-ubuntu-12-04
  • https://github.com/hexojs/hexo-util/issues/9

優雅地亂玩Linux-3-Ubuntu下NodeJS的安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.