Can't Install Mongoose via NPM
Asked Answered
L

6

11

I am trying to download mongoose into my node.js project via npm.

The command is npm install mongoose. However, this leads to the below output, and eventually leads to an error. The only things in the mongoose directory are the dependencies (in the node_modules folder). Any other package will work, but mongoose repeatedly fails. I've tried npm install -g mongoose and sudo npm install mongoose, but neither of them work either.

Any ideas what might be going wrong?

node version 0.10.20

npm version 1.3.11

$ npm install mongoose
npm WARN package.json [email protected] 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!     <[email protected]>

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  [email protected] { [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!     <[email protected]>

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!     <[email protected]>

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
Lalitta answered 3/10, 2013 at 4:43 Comment(2)
Any more info in the mentioned /Users/khanh/Code/bunnybots/npm-debug.log? Also, try running npm cache clean and try again.Blindheim
Cleaning the cache worked. I have all of the files now. Thanks!Lalitta
L
27

Use npm cache clean.

After that, install as normal, and the download should proceed correctly.

Lalitta answered 3/10, 2013 at 5:41 Comment(0)
B
0

stop node server if its running, that was the problem in my case

Brink answered 4/8, 2018 at 17:36 Comment(0)
F
0

I faced the same issue. Try this:

npm install -s mongoose

This will install it on your app, in fact on your package.json. It will be available as dependencies so you can easily require it.

Otherwise try

sudo npm install -g mongoose

That should also work, from your output above I can see that you haven't tried that.

Footgear answered 25/6, 2019 at 14:42 Comment(0)
K
0
  • Make index.js file in the folder where you have made the empty file of node using the command
    npm init
    
  • Now try to install mongoose using command
    npm install mongoose 
    

If this doesn't work

  • delete the folder in which you have made empty node project.
  • then again make the same folder and then use the above instruction.
Korey answered 27/8, 2021 at 11:31 Comment(0)
G
0

"npm cache clean --force ->> npm i mongoose" Worked for me.

Grandiloquence answered 16/12, 2021 at 20:48 Comment(0)
M
0

sudo chown -R 501:20 "/Users/{your user name}/.npm"

Run this in your terminal then run the package package install code

Muliebrity answered 5/8 at 0:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.