【发布时间】:2019-05-08 01:49:07
【问题描述】:
为了启动我的节点服务器,我必须在不同的终端选项卡中运行:
redis-servermongodnodemon app/app.js
我尝试在 package.json 中为它们制作一个脚本,如下所示:
"start": "redis-server && mongod && nodemon app/app.js"
但是在npm start 我收到下一个错误:
> server@1.0.0 start /Users/razbuchnik/Projects/taxi4you/server
> redis-server && mongod && npm run dev
790:C 06 Dec 13:11:32.993 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
790:C 06 Dec 13:11:32.994 # Redis version=4.0.8, bits=64, commit=00000000, modified=0, pid=790, just started
790:C 06 Dec 13:11:32.994 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
790:M 06 Dec 13:11:32.996 # Creating Server TCP listening socket *:6379: bind: Address already in use
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! server@1.0.0 start: `redis-server && mongod && npm run dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the server@1.0.0 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! /Users/razbuchnik/.npm/_logs/2018-12-06T11_11_33_004Z-debug.log
【问题讨论】:
-
错误无关。 redis 的一个实例已经在运行
TCP listening socket *:6379: bind: Address already in use -
关于你的其他问题,redis 和 mongo 可能需要额外的启动时间。因此并行运行它们可能仍会导致您的节点应用无法连接到数据库。
-
@AravindanVe 您的武器库中有什么解决方案吗?
标签: node.js npm package.json npm-scripts npm-start