簡體   English   中英

終端無法識別 nodemon 命令

[英]nodemon command not recognized by terminal

我正在嘗試使用 nodemon 自動重新加載服務器。 我已在本地安裝它並將開始設置為

nodemon app.js使用代碼:

"scripts": { "start": "nodemon app.js" }

第一次運行良好,但關閉系統一次並重新打開我的項目后,它似乎不再正常運行。 現在每次我使用命令nodemon app.js都會引發錯誤。

錯誤行是:

nodemon: The term 'nodemon' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

VS Code 終端中顯示的錯誤行

我可以解決的最佳解決方案是:

 npm install -D nodemon // install as a dev dependency

 npm start // run script start

下面是一些解決方案

  1. 這是安裝nodemon的方法
npm install -g nodemon

之后你必須運行這個命令: npm run dev here dev is (script) server name

  1. 之后,如果您遇到諸如“'nodemon' 未被識別為內部或外部命令、可運行程序或批處理文件之類的錯誤。”然后在全局安裝 nodemon 后寫入以下命令:
npm config get prefix

在 output 中,您將獲得 PATH ,然后通過此路徑進入環境變量並解決

重新啟動終端並運行此命令

nodemon run dev

我希望之后它會正常工作:)

暫無
暫無

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

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