为什么 nodemon 对我的 src/ 文件夹中的更改没有反应?
Why is nodemon not reacting to changes in my src/ folder?
当我的 src/
文件夹的子目录中的文件发生更改时,nodemon
不会对其更改做出反应,但是当项目中的其他文件发生更改时它会做出反应。
Screenshot of the folder structure
package.json
:
"dev": "nodemon src/server.ts",
nodemon.json
:
*
{
"watch": [".babelrc", "public/locales/**/*.json", "next.config.js", "src/server.ts"],
"exec": "ts-node --project tsconfig.server.json"
}
ts.config.server.json
:
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"noEmit": false,
"outDir": "build/"
},
"include": ["src/server.ts"]
}
和
ts.config.json
:
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"jsx": "preserve",
"lib": ["dom", "es2017"],
"baseUrl": ".",
"moduleResolution": "node",
"strict": true,
"allowJs": true,
"noEmit": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"isolatedModules": true,
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"exclude": ["dist", ".next", "out", "next.config.js"],
["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
你能显示 server.ts 文件吗?
您是否更改了 server.ts 中的所有导入路径?
我正在将 nodemon 与 gulp 一起使用,并且工作正常。
gulp.task('serve', function (done) {
nodemon({
script: 'server/server.js'
, ext: 'js html'
, env: { 'NODE_ENV': 'development' }
, done: done
})
})
在 nodemon.json 中尝试更改此:
"watch": [".babelrc", "public/locales/**/*.json", "next.config.js", "src/server.ts"],
对此:
"watch": [".babelrc", "public/locales/**/*.json", "next.config.js", "src/**/*.ts"],
@Paolo 的回答似乎对 .ts
文件有用!
为 .tsx
添加一个,但没有用。
最终的解决方案是添加一个具有 js json ts tsx
个值的 ext
字段!
决赛 nodemon.json
:
"watch": [".babelrc", "public/locales/**/*.json", "next.config.js", "src/**/*.ts", "src/**/*.tsx"],
"exec": "ts-node --project tsconfig.server.json",
"ext": "js json ts tsx"
}
当我的 src/
文件夹的子目录中的文件发生更改时,nodemon
不会对其更改做出反应,但是当项目中的其他文件发生更改时它会做出反应。
Screenshot of the folder structure
package.json
:
"dev": "nodemon src/server.ts",
nodemon.json
:
*
{
"watch": [".babelrc", "public/locales/**/*.json", "next.config.js", "src/server.ts"],
"exec": "ts-node --project tsconfig.server.json"
}
ts.config.server.json
:
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"noEmit": false,
"outDir": "build/"
},
"include": ["src/server.ts"]
}
和
ts.config.json
:
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"jsx": "preserve",
"lib": ["dom", "es2017"],
"baseUrl": ".",
"moduleResolution": "node",
"strict": true,
"allowJs": true,
"noEmit": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"isolatedModules": true,
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"exclude": ["dist", ".next", "out", "next.config.js"],
["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
你能显示 server.ts 文件吗? 您是否更改了 server.ts 中的所有导入路径?
我正在将 nodemon 与 gulp 一起使用,并且工作正常。
gulp.task('serve', function (done) {
nodemon({
script: 'server/server.js'
, ext: 'js html'
, env: { 'NODE_ENV': 'development' }
, done: done
})
})
在 nodemon.json 中尝试更改此:
"watch": [".babelrc", "public/locales/**/*.json", "next.config.js", "src/server.ts"],
对此:
"watch": [".babelrc", "public/locales/**/*.json", "next.config.js", "src/**/*.ts"],
@Paolo 的回答似乎对 .ts
文件有用!
为 .tsx
添加一个,但没有用。
最终的解决方案是添加一个具有 js json ts tsx
个值的 ext
字段!
决赛 nodemon.json
:
"watch": [".babelrc", "public/locales/**/*.json", "next.config.js", "src/**/*.ts", "src/**/*.tsx"],
"exec": "ts-node --project tsconfig.server.json",
"ext": "js json ts tsx"
}