我按照以下步骤构建了我的第一个 sailsjs MVC 应用程序:
sudo apt-get install nodejs
nodejs -v
返回 v0.10.25sudo apt-get install npm
npm -v
返回 1.3.10sudo npm install -g sails
之后我收到以下错误:
npm http GET https://registry.npmjs.org/sails
npm http 304 https://registry.npmjs.org/sails
npm WARN engine sails@0.11.3: wanted: {"node":">= 0.10.0","npm":">= 1.4.0"} (current: {"node":"v0.10.25","npm":"1.3.10"})
> sails@0.11.3 preinstall /usr/local/lib/node_modules/sails
> node ./lib/preinstall_npmcheck.js
sh: 1: node: not found
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
npm ERR! weird error 127
npm ERR! not ok code 0
最佳答案
尝试 sudo apt-get install nodejs-legacy
,似乎 debian 维护者将包重命名为该包。
此外,您还会在 sails 中收到警告,因为您有一个未满足的依赖版本。
如果你检查错误,它指出它需要哪个版本的 npm,它会说
"npm":">= 1.4.0"
但您的系统上有 1.3.10 版本。您需要 1.4.0 或更高版本。
尝试
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
查看是否更新了 npm
如果这不起作用,请尝试使用 nodeSource 中的存储库重新安装 Node
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
将 4.x
更改为所需的 Node 版本,但我建议您安装最新的 4.1.0(我知道它适用于 sails)
我有 ubuntu,所以我无法检查,但这应该可以。
如果上述方法均无效,另请检查下面的链接(不确定您的问题是否可以被视为重复)
<小时/>Cannot install packages using node package manager in Ubuntu
关于node.js - Nodejs、npm 和 sailsjs 之间是否存在版本依赖问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33973991/