使用 nodemon 观看文件夹
watching folder using nodemon
我正在尝试观察我的 src 文件夹中的变化,其中会有几个 js 文件。我怎样才能做到这一点?当我 运行 开发脚本时,我从索引文件而不是 world 和 hello 文件中获取 console.log。谁能解释我怎样才能让所有 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"
}
}
src 中的文件:
// 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。
我正在尝试观察我的 src 文件夹中的变化,其中会有几个 js 文件。我怎样才能做到这一点?当我 运行 开发脚本时,我从索引文件而不是 world 和 hello 文件中获取 console.log。谁能解释我怎样才能让所有 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"
}
}
src 中的文件:
// index.js
console.log('index.js')
// world.js
console.log('world.js')
// hello.js
console.log('hello.js')
Nodemon 启动一个 .js
文件作为入口点,这将是您的 index.js
。如果您的此文件不导入其他文件以执行其中的代码,您将看不到其他 console.log
.
您可以查看