我最近收到了一个由index.html、sass文件、javascript文件和一些配置文件组成的网站。我试图在主项目目录中运行命令npm install,得到了以下错误。
npm ERR! Error: No compatible version found: grunt-contrib-concat@'node_modules/grunt-contrib-concat'
npm ERR! Valid install targets:
npm ERR! ["0.1.0","0.1.1","0.1.2","0.1.3","0.2.0","0.3.0","0.4.0","0.5.0","0.5.1","1.0.0","1.0.1","0.1.2-rc5","0.1.2-rc6"]
npm ERR! at installTargetsError (/usr/share/npm/lib/cache.js:719:10)
npm ERR! at /usr/share/npm/lib/cache.js:638:10
npm ERR! at saved (/usr/share/npm/node_modules/npm-registry-client/lib/get.js:142:7)
npm ERR! at /usr/lib/nodejs/graceful-fs/polyfills.js:133:7
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
npm ERR! System Linux 4.4.0-x86_64-linode63
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /var/www/project.com/public_html_staging
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /var/www/project.com/public_html_staging/npm-debug.log
npm ERR! not ok code 0这就是我的package.json的样子
{
"name": "project",
"version": "0.0.0",
"devDependencies": {
"glob": "~4.3.1",
"grunt": "~0.4.1",
"grunt-autoprefixer": "~2.0.0",
"grunt-concat-css": "^0.3.1",
"grunt-contrib-concat": "node_modules/grunt-contrib-concat",
"grunt-contrib-connect": "~0.9.0",
"grunt-contrib-cssmin": "~0.11.0",
"grunt-contrib-imagemin": "^1.0.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-sass": "~0.8.1",
"grunt-contrib-uglify": "~0.7.0",
"grunt-contrib-watch": "~0.6.1"
},
"dependencies": {
"load-grunt-tasks": "~2.0.0"
}
}我对npm命令和任何相关的主题都非常陌生。如何开始排除此错误?还是有人知道解决方案?
发布于 2016-05-17 21:49:05
造成这个问题的原因是,我使用的是NodeJS版本0.1,而项目最初构建在一个具有NodeJS v5的服务器上。因此,npm没有完全正确的依赖关系。
我在受影响的服务器上以root用户的身份执行了以下操作
apt-get purge nodejs
apt-get purge npm
apt-get autoremove // remove any orphan dependences一旦我摆脱了一切,我按照NodeJS的网站安装了版本6的nodejs,并使用以下命令:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejsNodeJS已经有了自己的国家预防机制,所以我不需要做任何其他的事情。
然后,当我运行npm install时,它正确地下载了运行项目所需的所有模块。
https://stackoverflow.com/questions/37267417
复制相似问题