优雅地乱玩Linux-3-Ubuntu下NodeJS的安装

文章最初发表于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 sh
sudo 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.json

sh: 1: cannot create highlight_alias.json: Permission denied

换成sudo依然报错.

解决方法见官方Guide: https://docs.npmjs.com/getting-started/fixing-npm-permissions

参考文献

转载于:https://www.cnblogs.com/szhshp/p/6980455.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值