npm install -g nodemon
{
"name": "my-electron-app",
"version": "1.0.0",
"description": "Hello World!",
"main": "main.js",
"author": "Jane Doe",
"license": "MIT",
"scripts": {
"start": "nodemon --exec electron ." //这里
},
"devDependencies": {
"electron": "^28.1.0"
}
}
在文件根目录下创建nodemon.json文件, 记得重启,nodemon默认js文件可以重新加载,需要别的文件的话可以使用这个方法
{
"restartable": "rs",
"ignore": [".git", ".svn", "node_modules/**/node_modules"],
"verbose": true,
"execMap": {
"js": "node --harmony"
},
"watch": [],
"env": {
"NODE_ENV": "development"
},
"ext": "js html" //每次需要更新的文件后缀
}