node.js - npm install 终止并出现错误 "install Couldn' t 读取依赖项”

标签 node.js npm

当我在项目文件夹中运行 npm install 时,它会终止。
终端中显示错误 (MacOS X):

npm ERR! install Couldn't read dependencies
npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.4.3
npm ERR! npm  v2.15.1

npm ERR! Invalid version: "0.1.2.0"
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Orion/NodeWorks/WebDev/npm-debug.log

这里我附上了npm-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'install' ]
2 info using npm@2.15.1
3 info using node@v4.4.3
4 verbose readDependencies loading dependencies from /Users/Orion/NodeWorks/WebDev/package.json
5 error install Couldn't read dependencies
6 verbose stack Error: Invalid version: "0.1.2.0"
6 verbose stack     at Object.module.exports.fixVersionField (/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/lib/fixer.js:191:13)
6 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/normalize-package-data/lib/normalize.js:32:38
6 verbose stack     at Array.forEach (native)
6 verbose stack     at normalize (/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/lib/normalize.js:31:15)
6 verbose stack     at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:338:5)
6 verbose stack     at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:113:5)
6 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:232:12
6 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
6 verbose stack     at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
7 verbose cwd /Users/Orion/NodeWorks/WebDev
8 error Darwin 15.4.0
9 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
10 error node v4.4.3
11 error npm  v2.15.1
12 error Invalid version: "0.1.2.0"
13 error If you need help, you may report this error at:
13 error     <https://github.com/npm/npm/issues>
14 verbose exit [ 1, true ]

这是我的package.json:

{
  "name": "*****",
  "version": "0.1.2.0",
  "private": true,
  "description": "Packages for the web site ****.com",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server.js"
  },
  "author": "*****",
  "license": "ISC",
  "dependencies": {
    "async": "^2.0.0-rc.3",
    "bcryptjs": "^2.3.0",
    "body-parser": "^1.15.0",
    "cookie-parser": "^1.4.1",
    "debug": "^2.2.0",
    "del": "^2.2.0",
    "elasticsearch": "^11.0.1",
    "emailjs": "^1.0.4",
    "express": "^4.13.4",
    "express-session": "^1.13.0",
    "gulp-coffee": "^2.3.2",
    "gulp-concat": "^2.6.0",
    "gulp-imagemin": "^2.4.0",
    "gulp-sourcemaps": "^2.0.0-alpha",
    "gulp-uglify": "^1.5.3",
    "gulp-util": "^3.0.7",
    "html-metadata": "^1.4.1",
    "jade": "^1.11.0",
    "knex": "^0.10.0",
    "lodash": "^4.11.1",
    "mongoosastic": "^4.0.2",
    "mongoose": "^4.4.13",
    "morgan": "^1.6.1",
    "nodemailer": "^2.3.2",
    "passport": "^0.3.2",
    "passport-local": "^1.0.0",
    "python-shell": "^0.4.0",
    "q": "^1.4.1",
    "request": "^2.69.0",
    "serve-favicon": "^2.3.0",
    "speakingurl": "^9.0.0",
    "urlencode": "^1.1.0"
  },
  "devDependencies": {
    "chai": "^3.5.0",
    "grunt": "^1.0.1",
    "gulp": "^3.9.1",
    "gulp-jade": "^1.1.0",
    "mocha": "^2.4.5"
  }
}

我正在使用 npm 版本 2.15.1node 版本 v4.4.3

最佳答案

您的应用版本无效。 该版本应包含 3 个部分,而您有 4 个:

"version": "0.1.2.0"

将版本更新为此,它应该可以正常工作:

"version": "0.1.2"

NPM 正在使用 semver版本中有 3 个(不是四个)部分(主要、次要和补丁),以点号划分。

关于node.js - npm install 终止并出现错误 "install Couldn' t 读取依赖项”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36820716/

相关文章:

java - Maven 与 npm 类似吗?

node.js - 对周围的所有 Node JS 框架/库等感到困惑

c++ - 构造一个对象以在其他地方按值返回

node.js - 具有许多导入的 Node 中的依赖注入(inject)

node.js - 除了通过生成之外, Node 中是否有一种方法(某种 API)以编程方式调用本地 npm 发布

npm - 检查vuetify的版本

node.js - 使用 --生产选项和对等依赖项进行 npm install

node.js - Mongodb 类型引用 Node

node.js - 如何在 NodeJS 中创建视频 URL Blob?

proxy - 如何从 npm 代理中排除某些域