【/usr/bin/env: node: No such file or directory】 的解决办法

今早突然想升级下 npm,在 ubuntu (windows 10 子系统)下,输入了如下的命令:

$ sudo npm install npm -g
/usr/bin/env: ‘node’: No such file or directory

没成功,错误提示:/usr/bin/env: ‘node’: No such file or directory,
解决步骤还是老套路,
第一步,把错误提示拷贝到搜索引擎,找找
找到了 https://github.com/nodejs/node-v0.x-archive/issues/3911
别人遇到的一样的问题

也给出了两个解决方案(任选其一):

I’ve found this is often a misnaming error, if you install from a package manager you bin may be called nodejs so you just need to symlink it like so ln -s /usr/bin/nodejs /usr/bin/node

Just do
$ sudo apt-get install nodejs-legacy
https://github.com/volojs/volo#install

也有人把原因给发出来了,有兴趣八卦可以读一读,是关于 Debian 社区和 Node 社区之间的事儿:

@houmie (and everyone who comes across this bug in the future)
These explain why:
http://lists.debian.org/debian-devel-announce/2012/07/msg00002.html
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=614907
http://debian.2.n7.nabble.com/Node-js-and-it-s-future-in-debian-td1042211.html (only read this last thread if you’re a masochist)
As a Node developer, I would think hard before using Debian’s packaged version of node, and would use Ubuntu with chrislea’s PPA for Node or Debian stable with Node built from source in preference to the stock Debian nodejs package for the foreseeable future. The discussion on this bug makes clear that Debian has a very different idea of the role of Node in the wider world than most of the Node community.

    原文作者:善弈者通盘无妙手
    原文地址: https://www.jianshu.com/p/cde4b709e3f5
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞