【问题标题】:Can't Install Mongoose via NPM无法通过 NPM 安装 Mongoose
【发布时间】:2013-10-09 15:56:52
【问题描述】:

我正在尝试通过 npm 将 mongoose 下载到我的 node.js 项目中。

命令是npm install mongoose。但是,这会导致以下输出,并最终导致错误。 mongoose 目录中唯一的东西是依赖项(在 node_modules 文件夹中)。任何其他包都可以,但猫鼬一再失败。我试过npm install -g mongoosesudo npm install mongoose,但它们都不起作用。

有什么想法可能会出错吗?

节点版本 0.10.20

npm 版本 1.3.11

$ npm install mongoose
npm WARN package.json mongo@0.1.0 No repository field.
npm http GET https://registry.npmjs.org/mongoose
npm http 304 https://registry.npmjs.org/mongoose
npm http GET https://registry.npmjs.org/ms/0.1.0
npm http GET https://registry.npmjs.org/sliced/0.0.5
npm http GET https://registry.npmjs.org/hooks/0.2.1
npm http GET https://registry.npmjs.org/muri/0.3.1
npm http GET https://registry.npmjs.org/mongodb/1.3.19
npm http GET https://registry.npmjs.org/regexp-clone/0.0.1
npm http GET https://registry.npmjs.org/mpath/0.1.1
npm http GET https://registry.npmjs.org/mpromise/0.2.1
npm http 304 https://registry.npmjs.org/ms/0.1.0
npm http 304 https://registry.npmjs.org/sliced/0.0.5
npm http 304 https://registry.npmjs.org/hooks/0.2.1
npm http 304 https://registry.npmjs.org/muri/0.3.1
npm http 304 https://registry.npmjs.org/mongodb/1.3.19
npm http 304 https://registry.npmjs.org/regexp-clone/0.0.1
npm http 304 https://registry.npmjs.org/mpath/0.1.1
npm http 304 https://registry.npmjs.org/mpromise/0.2.1
npm ERR! Error: ENOENT, chmod '/Users/khanh/Code/bunnybots/node_modules/mongoose/node_modules/mongodb/index.js'
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 Darwin 11.4.2
npm ERR! command "/Users/khanh/.nvm/v0.10.20/bin/node" "/Users/khanh/.nvm/v0.10.20/bin/npm" "install" "mongoose"
npm ERR! cwd /Users/khanh/Code/bunnybots
npm ERR! node -v v0.10.20
npm ERR! npm -v 1.3.11
npm ERR! path /Users/khanh/Code/bunnybots/node_modules/mongoose/node_modules/mongodb/index.js
npm ERR! fstream_path /Users/khanh/Code/bunnybots/node_modules/mongoose/node_modules/mongodb/index.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call chmod
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /Users/khanh/.nvm/v0.10.20/lib/node_modules/npm/node_modules/fstream/lib/writer.js:305:19
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! error rolling back Error: ENOTEMPTY, rmdir '/Users/khanh/Code/bunnybots/node_modules/mongoose/node_modules/hooks'
npm ERR! error rolling back  mongoose@3.6.20 { [Error: ENOTEMPTY, rmdir '/Users/khanh/Code/bunnybots/node_modules/mongoose/node_modules/hooks']
npm ERR! error rolling back   errno: 53,
npm ERR! error rolling back   code: 'ENOTEMPTY',
npm ERR! error rolling back   path: '/Users/khanh/Code/bunnybots/node_modules/mongoose/node_modules/hooks' }
npm ERR! Error: ENOENT, open '/Users/khanh/Code/bunnybots/node_modules/mongoose/node_modules/mpath/package.json'
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 Darwin 11.4.2
npm ERR! command "/Users/khanh/.nvm/v0.10.20/bin/node" "/Users/khanh/.nvm/v0.10.20/bin/npm" "install" "mongoose"
npm ERR! cwd /Users/khanh/Code/bunnybots
npm ERR! node -v v0.10.20
npm ERR! npm -v 1.3.11
npm ERR! path /Users/khanh/Code/bunnybots/node_modules/mongoose/node_modules/mpath/package.json
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! Error: ENOENT, open '/Users/khanh/Code/bunnybots/node_modules/mongoose/node_modules/mpromise/README.md'
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 Darwin 11.4.2
npm ERR! command "/Users/khanh/.nvm/v0.10.20/bin/node" "/Users/khanh/.nvm/v0.10.20/bin/npm" "install" "mongoose"
npm ERR! cwd /Users/khanh/Code/bunnybots
npm ERR! node -v v0.10.20
npm ERR! npm -v 1.3.11
npm ERR! path /Users/khanh/Code/bunnybots/node_modules/mongoose/node_modules/mpromise/README.md
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/khanh/Code/bunnybots/npm-debug.log
npm ERR! not ok code 0

【问题讨论】:

  • 在提到的/Users/khanh/Code/bunnybots/npm-debug.log 中还有更多信息吗?另外,请尝试运行 npm cache clean 并重试。
  • 清理缓存有效。我现在有所有的文件。谢谢!

标签: node.js mongoose npm


【解决方案1】:

使用npm cache clean

之后,正常安装,下载应该会正常进行。

【讨论】:

    【解决方案2】:

    如果节点服务器正在运行,则停止它,这就是我的问题

    【讨论】:

      【解决方案3】:

      我遇到了同样的问题。试试这个:

      npm install -s mongoose
      

      这会将它安装在您的应用程序上,实际上是在您的package.json 上。它将作为依赖项提供,因此您可以轻松地require 它。

      否则试试

      sudo npm install -g mongoose
      

      这也应该有效,从您上面的输出中我可以看出您还没有尝试过。

      【讨论】:

        【解决方案4】:
        • 使用命令在你创建node的空文件的文件夹中创建index.js文件
          npm init
          
        • 现在尝试使用命令安装 mongoose
          npm install mongoose 
          

        如果这不起作用

        • 删除创建空节点项目的文件夹。
        • 然后再次创建相同的文件夹,然后使用上述说明。

        【讨论】:

          【解决方案5】:

          npm cache clean --force ->> npm i mongoose”为我工作。

          【讨论】:

            猜你喜欢
            • 2016-03-15
            • 2016-06-14
            • 2017-12-10
            • 2011-09-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2022-11-12
            • 2017-03-28
            相关资源
            最近更新 更多