簡體   English   中英

克隆后如何啟動我的 React 應用程序?

[英]How do I start my React App After I clone it?

我目前正在嘗試使用 netlify 部署我的應用程序,但問題是我將我的應用程序克隆到我的新計算機中,現在我遇到了一些問題。

> todolistv2@1.0.0 start /Users/hvaandres/Documents/GitHub/TodoList_React
> npm run build

npm ERR! missing script: build

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/hvaandres/.npm/_logs/2021-03-04T06_19_54_506Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todolistv2@1.0.0 start: `npm run build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the todolistv2@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/hvaandres/.npm/_logs/2021-03-04T06_19_54_546Z-debug.log

我運行了以下命令 npm install ,但我仍然遇到同樣的問題。 這是我的調試日志:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'deploy' ]
2 info using npm@6.14.11
3 info using node@v14.15.5
4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ]
5 info lifecycle todolistv2@1.0.0~predeploy: todolistv2@1.0.0
6 info lifecycle todolistv2@1.0.0~deploy: todolistv2@1.0.0
7 verbose lifecycle todolistv2@1.0.0~deploy: unsafe-perm in lifecycle true
8 verbose lifecycle todolistv2@1.0.0~deploy: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/hvaandres/Documents/GitHub/TodoList_React/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
9 verbose lifecycle todolistv2@1.0.0~deploy: CWD: /Users/hvaandres/Documents/GitHub/TodoList_React
10 silly lifecycle todolistv2@1.0.0~deploy: Args: [ '-c', 'npm run build && gh-pages -d build' ]
11 silly lifecycle todolistv2@1.0.0~deploy: Returned: code: 1  signal: null
12 info lifecycle todolistv2@1.0.0~deploy: Failed to exec deploy script
13 verbose stack Error: todolistv2@1.0.0 deploy: `npm run build && gh-pages -d build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1048:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid todolistv2@1.0.0
15 verbose cwd /Users/hvaandres/Documents/GitHub/TodoList_React
16 verbose Darwin 19.6.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "deploy"
18 verbose node v14.15.5
19 verbose npm  v6.14.11
20 error code ELIFECYCLE
21 error errno 1
22 error todolistv2@1.0.0 deploy: `npm run build && gh-pages -d build`
22 error Exit status 1
23 error Failed at the todolistv2@1.0.0 deploy script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]



我的 package.json:


{
  "name": "todolistv2",
  "version": "1.0.0",
  "description": "Todo-List",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "npm run build"
    
  },
  "keywords": [
    "react",
    "todolist_project"
  ],
  "author": "Alan A. Haro",
  "license": "ISC",
  "dependencies": {
    "react-icons": "^3.11.0"
  }
}

如果有人可以幫助我,我將不勝感激。 我只是想了解更多。

步驟1

您的系統中需要一個節點和 Npm 單擊此處安裝 Node.js 和 npm

第2步

刪除Package-lock.json文件

第 3 步

安裝節點模塊:

運行命令npm 安裝

第4步

運行命令npm 啟動

如果不起作用,請嘗試命令

npm 運行構建

或者

npm 運行開發

如果仍然無法正常工作,則打開 package.json 文件

並檢查

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "npm run build" // your script code is "npm run build"
  },

您的 package JSON 文件似乎缺少startbuild命令。 重新添加它們。這些是使用create-react-app新創建的 React 應用程序的默認值。 您似乎還缺少依賴項,即reactreact-dom

{
  "name": "todolistv2",
  "version": "1.0.0",
  "description": "Todo-List",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "react-scripts start",
    "build": "react-scripts build"
  },
  "keywords": [
    "react",
    "todolist_project"
  ],
  "author": "Alan A. Haro",
  "license": "ISC",
  "dependencies": {
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-icons": "^3.11.0",
    ... add any other missing dependencies!!
  }
}

暫無
暫無

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

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