npm在mac 10.7.5上安装错误

时间:2016-01-31 16:27:28

标签: node.js mongodb npm

我正在学习mongodb,作为学习过程的一部分,我安装了mongodbnodejsnpm。当我执行npm install指令时,这是我得到的错误:

me$ npm install
npm WARN package.json @ No repository field.
npm ERR! Darwin 11.4.2
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.2.2
npm ERR! npm  v2.14.7 

npm ERR! version not found: mongodb@3.2.1
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/me/Sites/mongodb/chapter1/npm-debug.log

这是package.json:

{
    "scripts": {
        "test": "gulp test",
        "watch": "gulp watch"
    },
    "dependencies": {
        "async": "0.9.0",
        "mongodb": "3.2.1"
    },
    "devDependencies": {
        "gulp": "3.8.11",
        "gulp-mocha": "2.0.1",
        "mocha": "2.2.4"
    }
}

我创建了一个名为mongodb的数据库,所以它可以看到它但是,我不知道出了什么问题。我读了npm安装错误“但没有任何指向类似的错误,所以我可以自己解决。请帮助!!

1 个答案:

答案 0 :(得分:0)

  

npm ERR!版本未找到:mongodb@3.2.1

这意味着mongodb软件包的版本3.2.1不存在(请参阅https://www.npmjs.com/package/mongodb - 当前,2.1.4中的最新版本)。

只需修改package.json中的版本号:

"dependencies": {
    "async": "0.9.0",
    "mongodb": "3.2.1"
},

"dependencies": {
    "async": "0.9.0",
    "mongodb": "^2.1.4"
},

然后重新运行npm install