Nodemon 卡在“因更改而重新启动..."并且不会重新启动服务器 [英] Nodemon stuck at "restarting due to changes..." and won't restart the server
问题描述
我有一个非常基本的 nodemon 配置.我正在修复我继承的这个遗留 node 7 项目,并试图让开发过程变得有点痛苦.首先,一个正确的重启和转换过程(因为它是使用 ES6 模块语法构建的).
I have a pretty basic nodemon configuration. I'm fixing this legacy node 7 project that I inherited and trying to make the development process a little bit painful. First thing first, a proper restart-and-transpile process (since it's built using ES6 modules syntax).
这是我的文件夹结构:
- src
|- index.js
- dist
|- index.js
- index.js
- nodemon.js
我运行 nodemon 作为 "start:dev": "nodemon index.js"
I run nodemon as "start:dev": "nodemon index.js"
内容如下:
// index.js
if (process.env.NODE_ENV === 'production') {
require('./dist/index.js');
} else {
require('babel-register')({});
require('babel-polyfill');
require('./src/index.js');
}
这个想法是在运行时转译代码,这样我就不必像以前那样手动停止服务器、重新转译、启动服务器.
The idea is that the code is transpiled on runtime, so that I don't have to stop server, re-transpile, start server manually, as I have been doing before.
最后但并非最不重要的是,nodemon 配置
Last but not least, nodemon config
// nodemon.js
{
"restartable": "rs",
"ignore": [
".git",
"node_modules/**/node_modules"
],
"verbose": true,
"watch": [
"src"
],
"env": {
"NODE_ENV": "development"
},
"ext": "js json"
}
我从 MERN 获取了这个设置,我认为它应该可以工作.但是,当我进行更改并保存时,它变成了:
I took this setup from MERN, and I think it should work. However, when I made a change and save, it goes:
[nodemon] files triggering change check: src/index.js
[nodemon] matched rule: /Users/me/project/path/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/index.js
(stuck here. it never restarts)
我一直在检查代码,我唯一不熟悉的可能是导致它的原因我能想到的是 child_process.execFileSync()
调用,这将调用java工具;和一个带有 mysql.createPool()
(mysql
包)的连接池.
I've been checking the code, and the only thing that I'm unfamiliar with, that maybe be causing it I can think of would be a child_process.execFileSync()
call, that will call a java tool; and a connection pool with mysql.createPool()
(mysql
package).
在 Node 7.5 和 Node 8.9 中都尝试过.知道哪里出了问题吗?
Tried both in Node 7.5 and Node 8.9. Any idea of what could be wrong?
推荐答案
我正在使用 window 10,并且在我不小心删除了 %PATH% 变量后遇到了这个问题.如果是这种情况,请尝试添加这三个路径:
I am using window 10, and I faced this issue after I accidentally removed my %PATH% variable. Try adding these three paths if it is the case:
C:\Windows;C:\Windows\system32;C:\Windows\System32\Wbem;
C:\Windows; C:\Windows\system32; C:\Windows\System32\Wbem;
这篇关于Nodemon 卡在“因更改而重新启动..."并且不会重新启动服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!