sudo apt-get install nodejs-legacy
也能够尝试node
ln -s /usr/bin/nodejs /usr/bin/node
本人是在安装hexo时出现的错误,即下列操做shell
npm install hexo-cli -g
错误信息中有以下信息npm
npm ERR! not ok code 0 npm WARN This failure might be due to the use of legacy binary "node" npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian
根据提示信息打开文件vim
vim /usr/share/doc/nodejs/README.Debian
文件中7-8行文字:hexo
The global search path for modules is /usr/lib/nodejs
32-40行文字:spa
The upstream name for the Node.js interpreter command is "node". In Debian the interpreter command has been changed to "nodejs". This was done to prevent a namespace collision: other commands use the same name in their upstreams, such as ax25-node from the "node" package. Scripts calling Node.js as a shell command must be changed to instead use the "nodejs" command.
从上述文中中能够看出 在debian中 可执行文件node已经被修改为nodejs
所以npm执行的过程当中找不到node可执行文件,故而出错。code
执行命令ip
ll /usr/bin/node*
结果:get
lrwxrwxrwx 1 root root 33 10月 22 2013 /usr/bin/node-gyp -> ../share/node-gyp/bin/node-gyp.js* -rwxr-xr-x 1 root root 1462424 3月 27 2014 /usr/bin/nodejs*
从结果可知,可执行文件node意见改为了nodejs,这也是找不到 node 以及 npm install 安装一些模块时失败的缘由
所以可执行文中开头的两种方法之一解决该问题io
再次执行
ll /usr/bin/node*
结果:
lrwxrwxrwx 1 root root 6 3月 27 2014 /usr/bin/node -> nodejs* lrwxrwxrwx 1 root root 33 10月 22 2013 /usr/bin/node-gyp -> ../share/node-gyp/bin/node-gyp.js* -rwxr-xr-x 1 root root 1462424 3月 27 2014 /usr/bin/nodejs*
此时再次执行npm相关的指令就OK了。