解決 Linux Bash 中的 Nodemon 命令未找到錯誤
    
    Yahya Irmak
    2022年5月11日
    
    Bash
    Bash Error
    
 
nodemon 是一個 Node.js 工具,它通過在檢測到目錄中的檔案更改時自動重新啟動節點應用程式來幫助開發應用程式。本文將解釋如何在 Linux Bash 中安裝 nodemon 並解決此錯誤。
解決 Linux Bash 中的 bash: nodemon: command not found 錯誤
    
你收到 bash: nodemon: command not found 錯誤,因為系統上未正確安裝 nodemon 工具。本文的其餘部分解釋了下載此工具的不同方法。
nodemon 工具可以使用以下命令安裝。
sudo npm install -g nodemon
如果即使在你的系統上安裝了 nodemon,你仍然收到 bash: nodemon: command not found 錯誤,請嘗試解除安裝並再次安裝它。
npm uninstall nodemon
sudo npm uninstall -g nodemon
--force 引數將強制 npm 安裝遠端資源,即使磁碟上存在本地副本。你也可以使用此選項重新安裝。
sudo npm install -g --force nodemon
--save-dev 引數用於儲存包以用於開發目的。嘗試使用此選項安裝 nodemon。
sudo npm install nodemon --save-dev
如果你進行了本地安裝,則系統路徑中將無法使用 nodemon。你可以使用 npx 命令在本地而不是全域性執行它。
npx nodemon app.js
你可能會收到此錯誤,因為 npm 未新增到系統路徑中。將以下命令新增到 .bashrc 檔案中。
export PATH=$PATH:~/npm
你可以通過從這些選項中選擇最適合你的工具來成功安裝 nodemon 工具。要檢查安裝,請檢查工具的版本。
nodemon --version
現在你可以在你的應用程式中使用 nodemon 工具。完成這些操作後,如果你的開發環境中仍然出現錯誤,請關閉應用程式並再次開啟它。
        Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe
    
作者: Yahya Irmak
    Yahya Irmak has experience in full stack technologies such as Java, Spring Boot, JavaScript, CSS, HTML.
LinkedIn