【问题标题】:No compatible version found: grunt-contrib-concat@'node_modules/grunt-contrib-concat'未找到兼容版本:grunt-contrib-concat@'node_modules/grunt-contrib-concat'
【发布时间】:2016-09-13 00:57:15
【问题描述】:

我最近收到了一个包含 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"
  }
}

我对@9​​87654325@ 命令和任何相关主题都很陌生。如何开始解决此错误?或者有谁知道解决办法吗?

【问题讨论】:

    标签: npm gruntjs


    【解决方案1】:

    问题是由于我使用的是 NodeJS 0.1 版,而该项目最初是在具有 NodeJS v5 的服务器上构建的。因此,npm 没有所有正确的 grunt 依赖项。

    我在受影响的服务器上以 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 时,它正确下载了运行我的项目所需的所有模块。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-25
      • 2017-08-07
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多