gpt4 book ai didi

node.js - 运行 npm start 会使进程在当前端口上运行,无论是否结束它

转载 作者:太空宇宙 更新时间:2023-11-04 02:22:37 24 4
gpt4 key购买 nike

我的应用程序正在运行一个端口:

var port = normalizePort(process.env.PORT || '9999');
app.set('port', port);

为了简单起见,我刚刚在目录中运行 Express 并创建了一个全新的 Express 应用程序。

问题:我运行 npm start 来启动我的应用程序。它运行良好,我还没有 gulp 任务设置。因此,我按 ctrl + c 取消,进行更改并再次运行 npm start

然后我收到这样的错误:

Port 9999 is already in use

npm ERR! Darwin 14.5.0
npm ERR! argv "node" "/usr/local/bin/npm" "start"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! example_test@0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1

所以我的进程仍在端口9999上运行,如何杀死该进程而不需要每次都找到该进程并杀死它。有没有办法可以取消该进程并同时杀死它?

谢谢!

最佳答案

npm start只运行 start script for a package .

使用node <initialization file>启动您的 Express 应用程序。例如:node server.js

关于node.js - 运行 npm start 会使进程在当前端口上运行,无论是否结束它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32397151/

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