2016-05-17 140 views
0

我最近收到的網站包含一個index.html,sass文件,javascript文件和一些配置文件。我試圖在主項目目錄中運行命令npm install,並且出現以下錯誤。未找到兼容版本:grunt-contrib-concat @'node_modules/grunt-contrib-concat'

npm ERR! Error: No compatible version found: [email protected]'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!  <[email protected]> 

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

這個問題是由於我使用的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 nodejs 

NodeJS已經有了它自己的npm,所以我不需要做其他任何事情。

然後當我運行npm install時,它正確下載了所有必要的模塊來運行我的項目。