使用nodemon监视文件夹



我正试图观察我的src文件夹中有几个js文件的变化。我怎样才能做到这一点呢?当我运行dev脚本时,我从索引文件中获得console.log,而不是从world和hello文件中获得。谁能解释一下我如何才能实现所有console.log的出现?

目录:

folder
├── src
|   ├── hello.js
|   ├── index.js
|   └── world.js
| .gitignore
| package.json
| README.md

package.json:

{
"name": "",
"version": "1.0.0",
"description": "",
"main": "src",
"scripts": {
"dev": "nodemon --watch src"
},
"author": "",
"license": "ISC",
"dependencies": {
"nodemon": "^2.0.14"
}
}

文件目录:

// index.js
console.log('index.js')
// world.js
console.log('world.js')
// hello.js
console.log('hello.js')

Nodemon启动单个.js文件作为入口点,这将是您的index.js。如果你的这个文件没有导入其他文件来执行其中的代码,你将看不到其他的console.log

你可以看看这个答案,看看如何在多个文件上并行运行nodemon。

最新更新