寻找特殊问题的帮助。每次我停止并重新启动服务器时,都会收到以下消息:
Jim@Jim-PC MINGW64 ~/nodeProjects/express-locallibrary-tutorial
$ npm start
> express-locallibrary-tutorial@0.0.0 start C:\Users\Jim\nodeProjects\express-locallibrary-tutorial
> node ./bin/www
Port 3300 is already in use
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! express-locallibrary-tutorial@0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the express-locallibrary-tutorial@0.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! C:\Users\Jim\AppData\Roaming\npm-cache\_logs\2017-09-19T17_39_10_578Z-debug.log
Run Code Online (Sandbox Code Playgroud)
我将端口更改为 3301,它可以工作。我停止并重新启动服务器并收到错误 3301 已在使用中。我将端口更改为 3302,它可以工作。停止并启动并得到 3302 已在使用中的错误。
几天前我停止使用 nodemon 解决另一个应用程序上的相同问题,它停止了。对于这个应用程序,我安装了 nodemon,但不是全局安装,遇到问题并卸载它。但问题仍然存在。
如果有人遇到过这个问题,我将不胜感激。
Tud*_*tin 12
如果您正在使用nodemon- 您可以这样处理:
将kill-portnode 包安装为 dev 依赖项:
npm install kill-port --save-dev
Run Code Online (Sandbox Code Playgroud)
nodemon.json在项目的根目录中创建一个文件,其中包含:
{
"events": {
"restart": "kill-port 3000",
"crash": "kill-port 3000"
},
"delay": "1500"
}
Run Code Online (Sandbox Code Playgroud)
然后,在你的package.json文件中,有这样的东西:
"scripts": {
"start-dev": "nodemon app.js",
}
Run Code Online (Sandbox Code Playgroud)
然后在开发模式下启动您的应用程序:
npm run start-dev
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2322 次 |
| 最近记录: |