簡體   English   中英

嘗試將 React Project 放在 github 頁上,但出現錯誤:npm ERR:缺少腳本:“部署”

[英]Trying to put React Project on github pages but I get error: npm ERR! Missing script: "deploy"

嘗試將 React Project 放在 Github 頁上,但出現錯誤:

npm ERR! Missing script: "deploy"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:

我按照以下步驟嘗試將反應項目放在 github 頁上:

Step 1
▶️ git remote add origin [YOUR REPO LINK]
▶️ git add -A
▶️ git commit -m "Initial commit"
▶️ git push -u origin main

Step 2
"homepage": "https://[USERNAME].github.io/[YOUR REPO NAME]",

Step 3
▶️ npm install gh-pages --save-dev

Step 4
"predeploy": "npm run build",
"deploy": "gh-pages -d build",

▶️ npm run deploy

但是當把 npm 運行部署在終端我得到錯誤有人知道如何解決它嗎? 我不明白為什么當我把它放在 m 腳本中並保存文件時它說腳本丟失:

"scripts": {
    "start": "react-scripts start",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },

你必須更新你的package.json文件。

添加這些屬性"predeploy": "npm run build""deploy": "gh-pages -d build"到現有scripts

在此處輸入圖像描述

暫無
暫無

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

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