Nodemon 不看文件
Nodemon not watching files
我在一个新文件夹上安装了 Nodemon,但我所做的任何更改都没有被监视。
我的 package.json 看起来像:
{
"name": "express",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"dev": "nodemon --watch ./ ./app.js"
},
"dependencies": {
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"express": "~4.17.1",
"http-errors": "~1.6.3",
"jade": "~1.11.0",
"morgan": "~1.9.1"
},
"config": {
"mongodbMemoryServer": {
"version": "latest"
}
},
"devDependencies": {
"nodemon": "^2.0.4"
}
}
目录结构类似于:
app.js
定义了所有要使用的中间件,但服务器创建和端口规范发生在 ./bin/www
.
我不确定为什么要遵循这种格式,但我被要求处理这个现有模板,我尝试设置 nodemon 以使开发过程更容易。
server creation and port specification happens in ./bin/www.
这意味着您需要 运行 ./bin/www
而不是 app.js
(您如何通过 运行ning 不包含该逻辑的文件来启动您的服务器).
你应该很适合
"dev": "nodemon ./bin/www"
I am not sure why this format is being followed
因为它使测试方式更容易(导出服务器对象并将其加载到您的测试文件中)。也是因为逻辑分离。
我在一个新文件夹上安装了 Nodemon,但我所做的任何更改都没有被监视。
我的 package.json 看起来像:
{
"name": "express",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"dev": "nodemon --watch ./ ./app.js"
},
"dependencies": {
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"express": "~4.17.1",
"http-errors": "~1.6.3",
"jade": "~1.11.0",
"morgan": "~1.9.1"
},
"config": {
"mongodbMemoryServer": {
"version": "latest"
}
},
"devDependencies": {
"nodemon": "^2.0.4"
}
}
目录结构类似于:
app.js
定义了所有要使用的中间件,但服务器创建和端口规范发生在 ./bin/www
.
我不确定为什么要遵循这种格式,但我被要求处理这个现有模板,我尝试设置 nodemon 以使开发过程更容易。
server creation and port specification happens in ./bin/www.
这意味着您需要 运行 ./bin/www
而不是 app.js
(您如何通过 运行ning 不包含该逻辑的文件来启动您的服务器).
你应该很适合
"dev": "nodemon ./bin/www"
I am not sure why this format is being followed
因为它使测试方式更容易(导出服务器对象并将其加载到您的测试文件中)。也是因为逻辑分离。