Windows中的NPM未安装模块或添加到package.json

时间:2016-03-15 10:31:17

标签: node.js windows npm

我不知道为什么我收到mongoskin的错误。我之前使用过这个模块,但我摆脱了它。我删除了node_modules目录然后执行了新的npm安装,很好的安装。然后我尝试添加一个新模块minimist,如下所示:

C:\www\instantynode\src>npm install minimist --save
npm WARN package.json instanty@0.1.1 No description
npm WARN package.json instanty@0.1.1 No repository field.
npm WARN package.json instanty@0.1.1 No README data
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "minimist" "--save"
npm ERR! node v4.4.0
npm ERR! npm  v2.14.20
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package mongodb@2.1.4 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer mongoskin@1.4.13 wants mongodb@~1.4

npm ERR! Please include the following file with any support request:
npm ERR!     C:\www\instantynode\src\npm-debug.log

的package.json:

{
  "name": "app",
  "version": "0.1.1",
  "description": "",
  "dependencies": {
    "bunyan": "1.5.1",
    "co": "4.6.0",
    "cookie-parser": "^1.4.0",
    "forever": "^0.15.1",
    "fs": "0.0.2",
    "geoip-lite": "^1.1.6",
    "handlebars": "^4.0.5",
    "jsonwebtoken": "^5.4.1",
    "jwt-simple": "^0.4.0",
    "koa": "^1.1.2",
    "koa-better-ratelimit": "^2.1.2",
    "koa-bodyparser": "^2.0.1",
    "koa-conditional-get": "^1.0.3",
    "koa-generic-session": "^1.10.0",
    "koa-handlebars": "^0.5.7",
    "koa-mount": "^1.3.0",
    "koa-multer": "1.0.0",
    "koa-passport": "^2.0.1",
    "koa-redis": "^1.0.1",
    "koa-router": "^5.3.0",
    "koa-static": "^1.5.2",
    "lodash": "^3.10.1",
    "mongodb": "2.1.4",
    "nodemailer": "2.1.0",
    "nodemon": "^1.8.1",
    "passport": "^0.3.2",
    "passport-http-bearer": "^1.0.1",
    "passport-local": "^1.0.0",
    "socket.io": "^1.3.7",
    "socketio-jwt": "^4.3.3"
  },
  "devDependencies": {
    "assert": "1.3.0",
    "del": "2.1.0",
    "gulp": "^3.9.1",
    "gulp-autoprefixer": "3.1.0",
    "gulp-concat": "2.6.0",
    "gulp-concat-css": "2.2.0",
    "gulp-imagemin": "2.4.0",
    "gulp-less": "3.0.5",
    "gulp-minify-css": "1.2.2",
    "gulp-notify": "2.2.0",
    "gulp-uglify": "1.5.1",
    "imagemin-pngquant": "4.2.0",
    "jsdoc": "3.4.0",
    "node-inspector": "0.12.5",
    "run-sequence": "1.1.5"
  },
  "main": "app.js",
  "scripts": {
    "startfn": "forever start -c \"nodemon --harmony\" app.js --exitcrash",
    "startf": "forever start -c \"node --harmony\" app.js",
    "start": "node --harmony app.js"
  },
  "author": "",
  "license": "ISC"
}

npm install minimist --save无法正常工作,无法安装或自行添加到package.json文件中。它仍然提到mongoskin

我觉得Windows中的NPM有问题?

4 个答案:

答案 0 :(得分:0)

您正在尝试安装minimist,它有自己的package.json及其自己的依赖项。在这些中它表示它想要安装mongoskin,它依赖于mongodb本身,但是在另一个版本中比你拥有它(你有2.1.4,但正如错误所说,它需要~1.4)。

因此,因为您提供了--save参数,所以您希望npm尊重这些依赖关系,并且不要在其上安装所需版本的mongodb。

答案 1 :(得分:0)

我认为mongoskin只适用于1.4以上的mongodb驱动程序。您可能已在全局模式下安装了mongoskin,尝试将其删除。

答案 2 :(得分:0)

好的,我发现了这个问题。 Windows中的NPM比Linux中的NPM更敏感。在Linux中,我可以手动从package.json文件中删除该行,只删除node_modules目录。但是在Windows中它似乎是由NPM缓存的,所以我不得不手动使用npm remove mongoskin --save命令。

当我这样做时,package.json看起来应该是我能够通过npm install minimist --save安装最小问题而没有问题!

我对Windows并不感到惊讶......并不感到惊讶......

答案 3 :(得分:0)

在你的package.json中,尝试更改它:

"mongodb": "2.1.4",

到此:

"mongodb": "1.4.*",