如何托管reactJS应用程序

问题描述 投票:0回答:1

我假设我应该能够将reactJS部署到AWS上的S3实例,但我不知道如何做到这一点。我在github上找到了publish-react-app,我正在尝试遵循这些步骤。当我执行npm run build时,我得到了这个错误流:

c:\jrs\PM_01\React>npm run build
npm ERR! missing script: build

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jonat\AppData\Roaming\npm-cache\_logs\2018-09-05T18_57_19_811Z-debug.log

c:\jrs\PM_01\React>npm run build

> [email protected] build c:\jrs\PM_01\React
> react-scripts build

'react-scripts' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build 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!     C:\Users\jonat\AppData\Roaming\npm-cache\_logs\2018-09-05T19_06_24_048Z-debug.log

我不知道我需要将什么放入package.json文件的scrips部分。这是我的package.json文件的样子:

{
  "name": "sample-app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server --open"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.25.0",
    "babel-loader": "^7.0.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-2": "^6.24.1",
    "css-loader": "^1.0.0",
    "style-loader": "^0.21.0",
    "webpack": "^2.6.1",
    "webpack-dev-server": "^2.4.5"
  },
  "dependencies": {
    "cors": "^2.8.4",
    "ebay-node-api": "^2.2.1",
    "moment": "^2.20.1",
    "moment-timezone": "^0.5.14",
    "publish-react-app": "^1.0.1",
    "react": "^15.6.2",
    "react-barcode": "^1.3.4",
    "react-dom": "^15.6.2",
    "react-moment": "^0.7.0",
    "react-redux": "^5.0.5",
    "react-router-dom": "^4.1.1",
    "redux": "^3.7.0",
    "reselect": "^3.0.1",
    "simple-flexbox": "^1.2.0"
  },
  "babel": {
    "presets": [
      [
        "es2015",
        {
          "modules": false
        }
      ],
      "stage-2",
      "react"
    ]
  }
}

我在AWS上创建了一个免费的层S3并创建了一个用户和一个存储桶,但我真的不知道还有什么办法可以部署我的应用程序。

谢谢。

reactjs amazon-s3 deployment
1个回答
0
投票

你的package.json缺少关键的build。通常使用诸如create-react-app之类的工具,它附带一个构建脚本来为生产准备资产。至于托管,Heroku很容易快速启动和运行。

© www.soinside.com 2019 - 2024. All rights reserved.