NPM从脚本启动Mongo时遇到麻烦

时间:2018-03-15 07:41:33

标签: node.js mongodb npm debian

我正在尝试在Debian 9中运行一个名为Streetmix的项目。我已尽力遵循安装说明。所以,当我在streetmix文件夹中使用NPM Start命令(有或没有sudo)时,我得到:

> streetmix@1.3.0 prestart /home/dpowell/streetmix/streetmix
> npm run mongo:start


> streetmix@1.3.0 mongo:start /home/dpowell/streetmix/streetmix
> mongod --fork --logpath /dev/null

about to fork child process, waiting until server is ready for connections.
forked process: 2076
ERROR: child process failed, exited with error number 100
npm ERR! code ELIFECYCLE
npm ERR! errno 100
npm ERR! streetmix@1.3.0 mongo:start: `mongod --fork --logpath /dev/null`
npm ERR! Exit status 100
npm ERR! 
npm ERR! Failed at the streetmix@1.3.0 mongo:start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-03-15T06_55_52_710Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 100
npm ERR! streetmix@1.3.0 prestart: `npm run mongo:start`
npm ERR! Exit status 100
npm ERR! 
npm ERR! Failed at the streetmix@1.3.0 prestart script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-03-15T06_55_52_721Z-debug.log

Streetmix上的说明我需要将mongodb / bin文件夹添加到$ PATH,但命令mongo --version可以从任何文件夹中运行,我认为这意味着因为mongo在usr / bin文件夹,它已经在我的$ PATH中了,对吗? (我还启动了mongod,然后是Mongo shell以确保它正常工作。我还创建了/ data / db文件夹。

有没有人对我的问题有什么了解?

以下是错误末尾提到的日志内容:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@5.6.0
3 info using node@v8.10.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle streetmix@1.3.0~prestart: streetmix@1.3.0
6 verbose lifecycle streetmix@1.3.0~prestart: unsafe-perm in lifecycle true
7 verbose lifecycle streetmix@1.3.0~prestart: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/dpowell/streetmix/streetmix/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
8 verbose lifecycle streetmix@1.3.0~prestart: CWD: /home/dpowell/streetmix/streetmix
9 silly lifecycle streetmix@1.3.0~prestart: Args: [ '-c', 'npm run mongo:start' ]
10 silly lifecycle streetmix@1.3.0~prestart: Returned: code: 100  signal: null
11 info lifecycle streetmix@1.3.0~prestart: Failed to exec prestart script
12 verbose stack Error: streetmix@1.3.0 prestart: `npm run mongo:start`
12 verbose stack Exit status 100
12 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
12 verbose stack     at emitTwo (events.js:126:13)
12 verbose stack     at EventEmitter.emit (events.js:214:7)
12 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
12 verbose stack     at emitTwo (events.js:126:13)
12 verbose stack     at ChildProcess.emit (events.js:214:7)
12 verbose stack     at maybeClose (internal/child_process.js:925:16)
12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
13 verbose pkgid streetmix@1.3.0
14 verbose cwd /home/dpowell/streetmix/streetmix
15 verbose Linux 4.9.0-6-amd64
16 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
17 verbose node v8.10.0
18 verbose npm  v5.6.0
19 error code ELIFECYCLE
20 error errno 100
21 error streetmix@1.3.0 prestart: `npm run mongo:start`
21 error Exit status 100
22 error Failed at the streetmix@1.3.0 prestart script.
22 error This is probably not a problem with npm. There is likely additional logging output above.
23 verbose exit [ 100, true ]

1 个答案:

答案 0 :(得分:2)

问题在于--fork。我遇到了同样的问题。

你需要做的是从package.json中删除prestart和mongo:start脚本,在一个单独的终端中打开mongodb。然后你可以像往常一样运行npm start!

P.S。确保您不提交此修改后的文件