gpt4 book ai didi

node.js - NPM 从脚本启动 Mongo 时遇到问题

转载 作者:太空宇宙 更新时间:2023-11-03 23:21:24 24 4
gpt4 key购买 nike

我正在尝试在 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 ]

最佳答案

问题出在 --fork 上。我也遇到了同样的问题。

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

附注确保您没有提交此修改后的文件

关于node.js - NPM 从脚本启动 Mongo 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49293913/

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