Nodejs資料之nodemon模塊

◆ 模塊作用:

nodemon是一個命令行工具,用以輔助項目開發。在Node.js中,可以在每次修改文件後重新執行該文件。

◆ 使用步驟:
  1. 使用npm install nodemon –g 下載
F:\workstation\nodejs> npm install nodemon -g
  1. 在命令行工具中用nodemon命令替代node命令執行文件

F:\workstation\nodejs> nodemon .\demo.js
[nodemon] 2.0.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node .\demo.js`
測試代碼
[nodemon] clean exit - waiting for changes before restart
◆ nodemon執行報錯處理:

報錯信息:

F:\workstation\nodejs> nodemon .\demo.js
nodemon : 無法加載文件 C:\Users\ASUS\AppData\Roaming\npm\nodemon.ps1,因爲在此係統上禁止運行腳本。有關詳細信息,請參閱
https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ nodemon .\demo.js
+ ~~~~~~~
    + CategoryInfo          : SecurityError: (:) [],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

解決方案:

管理員身份打開powerShell,輸入set-ExecutionPolicy RemoteSigned,選擇Y或者A。

F:\workstation\nodejs> set-ExecutionPolicy RemoteSigned

執行策略更改
執行策略可幫助你防止執行不信任的腳本。更改執行策略可能會產生安全風險,如 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 幫助主題所述。是否要更改執行策略?
[Y] 是(Y)  [A] 全是(A)  [N] 否(N)  [L] 全否(L)  [S] 暫停(S)  [?] 幫助 (默認值爲“N”): Y
發佈了293 篇原創文章 · 獲贊 6 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章