"scripts": {
"start": "npm run prod",
"build": "npm-run-all clean transpile",
"server": "node ./dist/bin/www",
"dev": "npm run lint && NODE_ENV=development nodemon --inspect=notifications:9236 --exec babel-node bin/www",
"prod": "NODE_ENV=production npm-run-all build server",
"transpile": "babel ./ --out-dir dist",
"lint": "eslint '*.js' ",
"lint:watch": "watch 'npm run lint' ",
"precommit": "npm run lint",
"prepush": "npm run lint",
"clean": "rimraf dist",
"test": "jest"
}
我在 docker 上有多個微服務,每個微服務的 package.json 中都包含類似的腳本。每當我進行更改并保存檔案時,nodemon 都不會檢測到更改并重新啟動服務器。
Nodemon 會在微服務啟動時啟動,輸出以下內容:
[nodemon] 2.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): **/* public/**/*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `babel-node --inspect=notifications:9236 bin/www`
我不得不提一下,這是一個基于 Mac OS 構建的專案,我目前正在 Windows 上運行它,如果它有任何相關性的話。
uj5u.com熱心網友回復:
它在 Windows 上是相關的,因為運行 unix 的容器中的檔案系統差異重復問題
如果您設定nodemon.json輪詢更改它應該更新,但它是非常昂貴的記憶體明智
{
"verbose": true,
"watch": ["src/**/*.ts"],
"exec": "ts-node ./src/index.ts",
"pollingInterval": 100,
"legacyWatch": true
}
uj5u.com熱心網友回復:
在您嘗試運行的任何啟動腳本中,您需要包含 nodemon
前任:
"start": "nodemon run prod"
uj5u.com熱心網友回復:
也許已經是這樣了,但是您是否將代碼檔案夾作為卷?因為如果您不使用卷與 dockerized 檔案共享本地更改,它不會更新,因為檔案將保持不變
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/418438.html
標籤:
上一篇:無法在Nodejs中讀取未定義的屬性(讀取“id”)
下一篇:試圖防止重復條目不起作用
