簡體   English   中英

nodemon 不斷崩潰等待文件更改

[英]nodemon keeps crashing waiting for file changes

克隆了一個我 2 個月前完成的項目,不幸的是,nodemon 無法運行。 我嘗試在 windows 上使用任務管理器關閉 npm 並再次運行它,但我仍然不斷收到相同的錯誤。 如果有幫助的話,我也使用 monogodb 作為我的數據庫。

如果有人可以提供幫助,我在此處留下了指向我的存儲庫的鏈接?

https://github.com/Tashfinz/ExpressNodeBlog

錯誤:

 $ nodemon server [nodemon] 2.0.4 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,json [nodemon] starting `node server global.js` C:\Users\tashf\Documents\Projects\ExpressNodeBlog\global.js:17 console.log(document.querySelector); ^ ReferenceError: document is not defined at Object.<anonymous> (C:\Users\tashf\Documents\Projects\ExpressNodeBlog\global.js:17:13) at Module._compile (internal/modules/cjs/loader.js:1251:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10) at Module.load (internal/modules/cjs/loader.js:1100:32) at Function.Module._load (internal/modules/cjs/loader.js:962:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47 [nodemon] app crashed - waiting for file changes before starting...

您需要終止節點服務器進程

在Windows,go到任務管理器並結束進程。

現在運行節點服務器:example-“nodemon server.js”

在大多數情況下,它應該可以工作,否則嘗試“npm install”重新安裝包,然后嘗試“nodemon server.js”。

我希望這會有所幫助。

卸載並重新安裝對我有用

npm un nodemon
npm i nodemon

原因及解決方法:

第一的:

也許您的 PC 在后台運行多個進程。 所以你需要停止所有正在運行的節點進程。

快速技巧:

通過在終端上運行以下命令將它們全部殺死:


pkill -f node

或者殺死一個特定的端口而不是所有


sudo lsof -i :3000//replace 3000 with your port number

sudo kill -9 31363// replace 31363 with your PID

然后重啟nodemon。

第二:

Server.js 和 package.json 不在同一個文件夾中。

檢查 package.json 文件。

在 MAIN YourNode.js 文件和 SCRIPT 中開始:nodemon YourNode.js 具有相同的名稱。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM