iT邦幫忙

0

npm安裝問題

00x1 2021-03-19 02:44:524100 瀏覽

本人是個新手,現在想進行前後端的交互,於是我用

npm install -g express-generator

到Visual Studio Code安裝時出現以下問題

PS D:\web\website> npm install -g express-generator
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)D:\Program Files(x86)\nodejs\node_global\express -> D:\Program Files(x86)\nodejs\node_global\node_modules\express-generator\bin\express-cli.js
+ express-generator@4.16.1
updated 1 package in 0.788s

而我使用

npm install mkdirp@1

會出現

npm install mkdirp@1
npm WARN website No description
npm WARN website No repository field.
npm WARN website No license field.

+ mkdirp@1.0.4
found 1 low severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

而我不管他直接用

express website

會出現以下error

express : File D:\Program Files (x86)\Nodejs\node_global\express.ps1 cannot be loaded. The file D:\Program Files (x86)\Nodejs\node_global\express.ps1 is not digitally signed. Y
ou cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https:/go.microsoft.co
m/fwlink/?LinkID=135170.
At line:1 char:1
+ express website
+ ~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

重裝VS,mkdir,nodejs也沒用
請問該如何解決?

EN iT邦好手 1 級 ‧ 2021-03-19 08:58:14 檢舉
試試看這個:
https://stackoverflow.com/questions/62859986/error-when-install-express-generator-using-npm
00x1 iT邦新手 5 級 ‧ 2021-03-19 12:22:55 檢舉
會出現同樣的問題,而我再用doctor查看時發現是
'''which git not ok Install git and ensure it's in your PATH.'''出了問題
00x1 iT邦新手 5 級 ‧ 2021-03-19 12:40:08 檢舉
已使用Set-ExecutionPolicy Restricted解決問題
謝謝
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1
screenleon
iT邦新手 1 級 ‧ 2021-03-19 09:19:37
最佳解答

你使用的npm install XXX,都有安裝成功,不清楚你是哪邊有問題
真正出問題的在express website

依照官方範例
請用以下指令執行express-generator

  1. express --view=hbs "你想要安裝得路徑" && cd "你想要安裝得路徑" 產生express 專案,並切換到該專案資料夾
  2. npm install 安裝所需套件
  3. npm start 執行專案

詳情請前往express-generator,查看文件

00x1 iT邦新手 5 級 ‧ 2021-03-19 12:25:30 檢舉

因為'''express --view=hbs "你想要安裝得路徑" && cd "你想要安裝得路徑"'''是UNIX語法 而我用express --view=hbs websit或express website會有同樣的express.ps1沒有權限問題

00x1 iT邦新手 5 級 ‧ 2021-03-19 12:40:03 檢舉

已使用Set-ExecutionPolicy Restricted解決問題
謝謝

有幫助到你的話 標個最佳解答八/images/emoticon/emoticon25.gif

我要發表回答

立即登入回答