gpt4 book ai didi

macos - npm install -g mongodb 没有在 OSX 10.8.4 上全局安装 mongodb?

转载 作者:IT老高 更新时间:2023-10-28 12:29:08 28 4
gpt4 key购买 nike

我知道有人问过类似的问题,但我找不到我的具体情况。我只是想在全局范围内安装 mongodb,以便我可以通过键入 mongod 从任何目录运行它,而不是在特定的 bin 中并键入有效的 ./mongod。尝试时出现此错误:

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 但这只有在我每次 session 都输入终端时才有效。我以前有过它,因此我可以从任何目录中简单地键入 mongomongod,但我在新计算机上遇到了问题。谢谢你。

我删除了 usr/local/lib/node_modules 文件夹中的 mongodb 目录,然后运行了

$ 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 吗?

我也尝试了自制软件,但没有成功:

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

最佳答案

您正在安装 MongoDB 驱动程序,而不是 MongoDB,因此仅使用驱动程序,您将无法通过命令行访问 mongodmongo。尝试遵循 MongoDB OS X 安装说明:

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

关于macos - npm install -g mongodb 没有在 OSX 10.8.4 上全局安装 mongodb?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19840354/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com