我最近收到的网站包含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
命令和任何相关主题都不熟悉。如何开始排除此错误?或者有人知道解决方案吗?
答案 0 :(得分:0)
问题是由于我使用NodeJS版本0.1而项目最初是在具有NodeJS v5的服务器上构建的。因此,npm没有所有正确的grunt依赖。
我在受影响的服务器上以root用户身份执行了以下操作
apt-get purge nodejs
apt-get purge npm
apt-get autoremove // remove any orphan dependences
一旦我摆脱了一切,我按照nodejs网站使用以下命令安装NodeJS的第6版:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
NodeJS已经附带了它自己的npm,所以我不需要做任何其他事情。
然后当我运行npm install
时,它正确地下载了所有必要的模块来运行我的项目。