6

I know similar questions have been asked to death, but I can't find my particular situation. I'm just trying to install mongodb globally so that I may run it from any directory by typing mongod instead of being in the specific bin and typing ./mongod which works. I get this error when trying:

Squirrels-MacBook-Air:Code Squirrel$ npm install -g mongodb 
npm http GET https://registry.npmjs.org/mongodb
npm http 304 https://registry.npmjs.org/mongodb
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/mongodb'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/mongodb']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/mongodb',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/mongodb',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 12.4.1
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "mongodb"
npm ERR! cwd /Users/Squirrel/Documents/Code
npm ERR! node -v v0.10.21
npm ERR! npm -v 1.3.11
npm ERR! path /usr/local/lib/node_modules/mongodb
npm ERR! fstream_path /usr/local/lib/node_modules/mongodb
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/mongodb'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/Squirrel/Documents/Code/npm-debug.log
npm ERR! not ok code 0

So I did sudo npm install mongodb -g:

Squirrels-MacBook-Air:~ Squirrel$ sudo npm install mongodb -g 
Password:
npm http GET https://registry.npmjs.org/mongodb
npm http 304 https://registry.npmjs.org/mongodb
npm http GET https://registry.npmjs.org/bson/0.2.2
npm http GET https://registry.npmjs.org/kerberos/0.0.3
npm http 304 https://registry.npmjs.org/bson/0.2.2
npm http 304 https://registry.npmjs.org/kerberos/0.0.3

> kerberos@0.0.3 install /usr/local/lib/node_modules/mongodb/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)


> bson@0.2.2 install /usr/local/lib/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)

mongodb@1.3.19 /usr/local/lib/node_modules/mongodb
├── kerberos@0.0.3
└── bson@0.2.2

But still it's not global. I've also tried export PATH=/path/to/mongodb/bin:$PATH but that only works if I type it into terminal each session. I've had it before so that I could simply type mongo or mongod from any directory, but I'm having trouble on my new computer. Thank you.

I deleted the mongodb directory within the usr/local/lib/node_modules folder, and than I ran

$ sudo find / -name mongod 
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/Users/Squirrel/.npm/mongod
/Users/Squirrel/.Trash/mongodb-osx-x86_64-2.4.8/bin/mongod
/Users/Squirrel/.Trash/mongodb-osx-x86_64-2.4.8 6.43.25 PM/bin/mongod
/Users/Squirrel/.Trash/mongodb-osx-x86_64-2.4.8 6.57.12 PM/bin/mongod
/Users/Squirrel/.Trash/mongodb-osx-x86_64-2.4.8 7.18.50 PM/bin/mongod
/Users/Squirrel/Documents/Code/mongodb-osx-x86_64-2.4.8/bin/mongod

Should i rm -r /Users/Squirrel/.npm/mongod ?

I also tried homebrew with no luck:

$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" brew install mongodb

Squirrl
  • 4,909
  • 9
  • 47
  • 85

2 Answers2

5

You're installing the MongoDB driver, not MongoDB, so with only the driver, you won't be able to access mongod or mongo via the command line. Try following the MongoDB OS X install directions:

http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/

EmptyArsenal
  • 7,314
  • 4
  • 33
  • 56
  • 1
    I'm tried that before. Do i need to do both? Install mongodb, create a data/db directory in my root, run chmod 777, and than npm install -g mongod? – Squirrl Nov 07 '13 at 16:53
  • If typing in `mongod` from your command line isn't working, there must be a problem with your MongoDB install, not the driver. I would take on these problems in order. Try to focus on getting a proper MongoDB install first, and then figure out the node driver. Does it list a version if you type in `mongodb --version`? You might want post a new question with more specific info on your MongoDB install only. – EmptyArsenal Nov 07 '13 at 17:04
  • It does not. I can get an instance running when I'm in the bin folder and I type `./mongod` or `./mongo`, but if i run `mongo app.js` or just `mongo` it says `mongo: command not found` Thanks I really appreciate ur help. – Squirrl Nov 07 '13 at 17:09
  • Does this fix it? http://stackoverflow.com/questions/10203589/cant-use-mongo-command-shows-command-not-found-on-mac – EmptyArsenal Nov 07 '13 at 17:14
  • No, It doesn't. I made some edits up top. Is there a clean way to get rid of everything mongo so I can try again? – Squirrl Nov 07 '13 at 17:35
  • Not an expert on this, but I had to remove it a couple of times and I did `brew uninstall`, removed the data directory, and the lock file. If that's not enough info to do the trick, I'd post a new question as I'm not an expert on it. – EmptyArsenal Nov 07 '13 at 17:52
  • thanks for trying. I also tried homebrew with no luck: `$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"` `brew install mongodb` – Squirrl Nov 07 '13 at 20:32
  • http://www.mkyong.com/mongodb/how-to-install-mongodb-on-mac-os-x/comment-page-1/#comment-139566 saved my life. For some reason it's the only one that worked and now I will not jump out of my window. THank u so much for being the only to one to try and help me. Should I try to delete all other instances of mongodb or does it not matter? Answer that and I will award u the green checkmark. THanks again. – Squirrl Nov 07 '13 at 21:05
  • Haha, love the green checkmarks. If you want to clean up some hard drive space, I'd remove them (particularly if you can do it easily), but otherwise if it ain't broke, don't fix it! – EmptyArsenal Nov 07 '13 at 21:08
0

run ps -xa | grep mongod and you don't see a --dbpath which explicitly tells mongod to look at that parameter for the db location and you don't have a dbpath in your mongodb.conf, then the default location will be: /data/db/ and you should look there.

Jackal
  • 2,591
  • 3
  • 25
  • 29