【发布时间】:2020-12-30 20:47:50
【问题描述】:
我一直在这个帖子上寻找答案:Node / Express: EADDRINUSE, Address already in use - Kill server
虽然我不认为它回答了我的问题,因为我不想杀死正在运行的进程而是重新启动服务。
$ npm run start
> graphql-basics@1.0.0 start /home/phill/Documents/graphql-course/graphql-basics
> nodemon src/index.js --exec babel-node
[nodemon] 1.17.5
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node src/index.js`
The server is up!
[nodemon] restarting due to changes...
[nodemon] starting `babel-node src/index.js`
events.js:174
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::4000
基本上它会重启服务器而不杀死之前的进程?
手动终止进程不会解决此问题
这是我的package.json
{
"name": "graphql-basics",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon src/index.js --exec babel-node",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"graphql-yoga": "^1.14.10"
},
"devDependencies": {
"nodemon": "^1.17.5"
}
}
const server = new GraphQLServer({
typeDefs,
resolvers
})
server.start(() => {
console.log('The server is up!')
})
//should i use process.on('SIGTERM',...) and kill it somehow?
【问题讨论】:
-
尝试从启动脚本中删除`--exec babel-node`,然后手动终止进程,然后再次
npm start -
你试过了吗?没有它我无法运行
graphql