简体   繁体   English

尝试将 React 应用程序部署到 Heroku 时出错

[英]Error while trying to deploy React app to Heroku

I'm keep getting the following error when I'm trying to deploy to heroku:当我尝试部署到 heroku 时,我不断收到以下错误:

remote: sh: 1: react-scripts: Permission denied远程:sh:1:反应脚本:权限被拒绝

The app compiles and workes well locally, so i'm pretty sure it's something with the deployment settings.该应用程序在本地编译并运行良好,所以我很确定它与部署设置有关。

I can't understand what's wrong... here is my nodejs server package.json :我不明白出了什么问题......这是我的nodejs服务器package.json

{
  "name": "app-server",
  "version": "1.0.0",
  "description": "Create-react-app with Express",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js",
    "heroku-postbuild": "cd client && npm install && npm run build"
  },
  "author": "Roy",
  "license": "ISC",
  "dependencies": {
    "axios": "^0.19.0",
    "cors": "^2.8.4",
    "dotenv": "^8.1.0",
    "express": "^4.16.3"
  },
  "engines": {
    "node": "10.5.0"
  }
}

And here is my client package.json这是我的客户 package.json

{
  "name": "client",
  "version": "0.1.0",
  "private": false,
  "dependencies": {
    "@material-ui/core": "^4.4.1",
    "axios": "^0.19.0",
    "color-temperature": "^0.2.7",
    "concurrently": "^4.1.2",
    "cors": "^2.8.5",
    "downshift": "^3.2.14",
    "express": "^4.17.1",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "path": "^0.12.7",
    "prop-types": "^15.7.2",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-md": "^1.12.3",
    "react-moment": "^0.9.2",
    "react-redux": "^7.0.2",
    "react-reveal": "^1.2.2",
    "react-router-dom": "^5.0.0",
    "react-scripts": "2.1.8",
    "react-toastify": "^5.3.2",
    "reactstrap": "^8.0.1",
    "redux": "^4.0.1",
    "redux-thunk": "^2.3.0"

  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },

  "proxy": "http://localhost:5000"
}

And here is the full error这是完整的错误

  remote: sh: 1: react-scripts: Permission denied
    remote: npm ERR! code ELIFECYCLE
    remote: npm ERR! errno 126
    remote: npm ERR! client@0.1.0 build: `react-scripts build`
    remote: npm ERR! Exit status 126
    remote: npm ERR!
    remote: npm ERR! Failed at the client@0.1.0 build script.
    remote: npm ERR! This is probably not a problem with npm. There is likely additional logging 
    output above.
    remote:
    remote: npm ERR! A complete log of this run can be found in:
    remote: npm ERR!     /tmp/npmcache.cG6aC/_logs/2019-09-20T12_27_39_563Z-debug.log
    remote: npm ERR! code ELIFECYCLE
    remote: npm ERR! errno 126
    remote: npm ERR! weather-app-server@1.0.0 heroku-postbuild: `cd client && npm install && npm run 
     build`
    remote: npm ERR! Exit status 126
    remote: npm ERR!
    remote: npm ERR! Failed at the weather-app-server@1.0.0 heroku-postbuild script.
    remote: npm ERR! This is probably not a problem with npm. There is likely additional logging 
    output above.
    remote:
    remote: npm ERR! A complete log of this run can be found in:
    remote: npm ERR!     /tmp/npmcache.cG6aC/_logs/2019-09-20T12_27_39_576Z-debug.log
    remote:
    remote: -----> Build failed
    remote:
    remote:        We're sorry this build is failing! You can troubleshoot common issues here:
    remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
    remote:
    remote:        If you're stuck, please submit a ticket so we can help:
    remote:        https://help.heroku.com/
    remote:
    remote:        Love,
    remote:        Heroku
    remote:
    remote:  !     Push rejected, failed to compile Node.js app.
    remote:
    remote:  !     Push failed
  1. Have you ignored node modules?您是否忽略了节点模块?
  2. Have you checked that all module installations were correct without errors?您是否检查过所有模块安装正确无误?
  3. In your client package.json the proxy is localhost.在您的客户端 package.json 中,代理是 localhost。 Try to replace it with your backend url.尝试用您的后端 url 替换它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM