npm install -g mongodb不能在OSX 10.8.4上全局安装mongodb吗? [英] npm install -g mongodb not installing mongodb globally on OSX 10.8.4?
问题描述
我知道有人问过类似的问题,但是我找不到我的特殊情况.我只是想在全球范围内安装mongodb,以便我可以通过输入mongod
在任何目录中运行它,而不是在特定的bin中并输入有效的./mongod
.尝试时出现此错误:
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
所以我做了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
但是它仍然不是全球性的.我也尝试过export PATH=/path/to/mongodb/bin:$PATH
,但是仅当我在每个会话的终端中键入它时,它才起作用.我以前有过它,所以我可以从任何目录中简单地键入mongo
或mongod
,但是我在新计算机上遇到了麻烦.谢谢你.
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.
我删除了usr/local/lib/node_modules文件夹中的mongodb目录,然后运行了
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
我应该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
推荐答案
您正在安装MongoDB驱动程序,而不是MongoDB,因此仅使用该驱动程序,您将无法通过以下方式访问mongod
或mongo
命令行.尝试按照MongoDB OS X的安装说明进行操作:
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/
这篇关于npm install -g mongodb不能在OSX 10.8.4上全局安装mongodb吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!