简体   繁体   English

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

[英]NPM in Windows not installing module or adding to package.json

I have no idea why I get an error for mongoskin . 我不知道为什么我会误以为是mongoskin I used this module before but I got rid of it. 我以前使用过此模块,但摆脱了它。 I removed the node_modules directory then did a fresh npm install, fine everything installs. 我删除了node_modules目录,然后进行了全新的npm安装,对所有安装进行了完善。 Then I tried to add a new module minimist as seen below: 然后,我尝试添加一个新的模块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: 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 does not work as you can see, does not install or add itself to the package.json file. 如您所见, npm install minimist --save无法正常工作,不会将自身安装或添加到package.json文件中。 And it is still mentioning mongoskin ? 而且还提到mongoskin吗?

I have a feeling that the NPM in Windows is buggy? 我感觉Windows中的NPM有问题吗?

You are trying to install minimist, which has its own package.json with its own dependencies. 您正在尝试安装minimist,它具有自己的package.json和自己的依赖项。 In these it says that it wants mongoskin to be installed, which has a dependency on mongodb itself, but in another version than you have it (you have 2.1.4 but as the error says, it needs ~1.4). 在这些文件中,它表示希望安装mongoskin,它依赖于mongodb本身,但是在另一个版本中,您拥有它(您拥有2.1.4,但正如错误所言,它需要〜1.4)。

So, because you provided the --save parameter, you want npm to respect these dependencies and do not install mongodb in the desired version on top of it. 因此,由于提供了--save参数,因此您希望npm遵守这些依赖性,并且不要在所需的版本上安装mongodb。

i think that mongoskin only work with mongodb driver older than 1.4. 我认为mongoskin仅适用于早于1.4的mongodb驱动程序。 You might have installed mongoskin in global mode, try to remove it. 您可能已在全局模式下安装了mongoskin,请尝试将其删除。

Ok I've found the issue. 好的,我找到了问题。 The NPM in Windows is way more sensitive than the one in Linux. Windows中的NPM比Linux中的NPM更敏感。 In Linux I can manually remove the line from the package.json file and just remove the node_modules directory. 在Linux中,我可以从package.json文件中手动删除该行,而仅删除node_modules目录。 However in Windows it appears to be cached by NPM, so I had to manually use the npm remove mongoskin --save command. 但是在Windows中,它似乎是由NPM缓存的,因此我不得不手动使用npm remove mongoskin --save命令。

When I did this so that the package.json looked like it should I was able to install minimist via npm install minimist --save without issues! 当我这样做时,使package.json看起来应该可以通过npm install minimist --save没有问题!

I'm not surprised Windows... Not surprised... 我不惊讶Windows ...不惊讶...

In your package.json, try to change this: 在您的package.json中,尝试更改此设置:

"mongodb": "2.1.4",

to this: 对此:

"mongodb": "1.4.*",

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM