如果代码库中缺少特定文件,是否可以中断/终止 npm start
进程?
如果文件 dev-variables.js
不存在,我想终止该进程,最好带有“您缺少 dev-variables.js 文件”这样的自定义错误。
最佳答案
使用预启动
https://docs.npmjs.com/misc/scripts
"scripts": {
"prestart": "scripts/check-dev-variables.js"
}
如果找不到文件,scripts/check-dev-variables.js
将抛出异常
关于javascript - 如果存储库中不存在文件,则终止 npm start 并显示自定义错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58248306/