尝试将react.js应用程序部署到heruko

时间:2019-07-08 11:53:21

标签: reactjs heroku npm deployment yarnpkg

好的,所以我需要将我的react.js应用程序部署到heroku,但这总是给我一个错误。

该应用程序使用yarn而不是npm。该应用程序基于保险丝React模板构建。我已经在package.json中将引擎指定为yarn和node,但是它一直给我一个错误。请参阅下面的代码,以加深了解。

这是我的package.json文件

{
"name": "fuse-react-app",
"version": "3.1.0",
"private": true,
"engines": {
    "yarn": "1.15.2",
    "node": "10.16.0"
},
"dependencies": {
    "@date-io/date-fns": "1.3.7",
    "@material-ui/core": "4.1.3",
    "@material-ui/icons": "4.2.1",
    "@material-ui/pickers": "3.1.2",
    "@material-ui/styles": "4.1.2",
    "auth0-lock": "11.16.3",
    "autosuggest-highlight": "3.1.1",
    "axios": "0.19.0",
    "axios-mock-adapter": "1.16.0",
    "chart.js": "2.8.0",
    "date-fns": "2.0.0-beta.1",
    "downshift": "3.2.10",
    "firebase": "6.2.3",
    "formsy-react": "1.1.5",
    "google-map-react": "1.1.4",
    "jsonwebtoken": "8.5.1",
    "jss": "10.0.0-alpha.21",
    "jss-extend": "6.2.0",
    "jwt-decode": "2.2.0",
    "keycode": "2.2.0",
    "lodash": "4.17.11",
    "material-table": "1.40.0",
    "material-ui-popup-state": "1.4.0",
    "mobile-detect": "1.4.3",
    "moment": "2.24.0",
    "notistack": "0.8.7",
    "path-to-regexp": "3.0.0",
    "perfect-scrollbar": "1.4.0",
    "prismjs": "1.16.0",
    "qs": "6.7.0",
    "raw-loader": "1.0.0",
    "react": "16.8.6",
    "react-autosuggest": "9.4.3",
    "react-beautiful-dnd": "11.0.4",
    "react-big-calendar": "0.22.0",
    "react-chartjs-2": "2.7.6",
    "react-dom": "16.8.6",
    "react-draggable": "3.3.0",
    "react-frame-component": "4.1.0",
    "react-masonry-css": "1.0.12",
    "react-number-format": "4.0.8",
    "react-popper": "1.3.3",
    "react-redux": "7.1.0",
    "react-router-config": "5.0.1",
    "react-router-dom": "5.0.1",
    "react-scripts": "3.0.1",
    "react-select": "2.4.4",
    "react-swipeable-views": "0.13.3",
    "react-table": "6.10.0",
    "react-text-mask": "5.4.3",
    "react-virtualized": "9.21.1",
    "react-window": "1.8.3",
    "redux": "4.0.1",
    "redux-thunk": "2.3.0",
    "typeface-muli": "0.0.71",
    "velocity-react": "1.4.3"
},
"resolutions": {
    "react": "16.8.6",
    "react-dom": "16.8.6"
},
"devDependencies": {
    "@babel/core": "7.4.5",
    "@babel/node": "7.4.5",
    "@babel/preset-env": "7.4.5",
    "cross-env": "5.2.0",
    "globby": "9.2.0",
    "js-beautify": "1.10.0",
    "marked": "0.6.2",
    "purgecss": "1.3.0",
    "tailwindcss": "1.0.4",
    "webpack-bundle-analyzer": "3.3.2"
},
"scripts": {
    "start": "yarn run tailwind && react-scripts start",
    "build": "yarn run tailwind && node ./purge-tailwindcss.js && cross-env GENERATE_SOURCEMAP=false react-scripts build",
    "tailwind": "./node_modules/.bin/tailwind build ./src/styles/tailwind.base.css -c ./tailwind.js -o ./src/styles/tailwind.css",
    "test": "react-scripts test --env=node",
    "eject": "react-scripts eject",
    "build-docs": "find ./src/app/main/documentation/material-ui-components \\( -name '*.ts' -o -name '*.tsx' \\) -type f -delete && babel-node src/app/main/documentation/material-ui-components/build.js",
    "build-stats": "yarn run build --stats",
    "bundle-report": "yarn run build-stats && webpack-bundle-analyzer build/bundle-stats.json -m static -r build/bundle-stats.html -O"
},
"eslintConfig": {
    "extends": "react-app"
},
"browserslist": {
    "production": [
        ">0.2%",
        "not dead",
        "not op_mini all"
    ],
    "development": [
        "last 1 chrome version",
        "last 1 firefox version",
        "last 1 safari version",
        "ie 11"
    ]
 }
}

这是我在heroku上遇到的错误:

  

2019-07-08T11:25:56.852293 + 00:00 app [web.1]:npm错误!产生ENOENT   2019-07-08T11:25:56.852517 + 00:00 app [web.1]:npm错误!   2019-07-08T11:25:56.852647 + 00:00 app [web.1]:npm错误!在fuse-react-app@3.1.0启动脚本处失败。   2019-07-08T11:25:56.852779 + 00:00 app [web.1]:npm错误! npm可能不是问题。上面可能还有其他日志记录输出。   2019-07-08T11:25:56.860485 + 00:00 app [web.1]:   2019-07-08T11:25:56.860724 + 00:00 app [web.1]:npm错误!可以在以下位置找到此运行的完整日志:   2019-07-08T11:25:56.860877 + 00:00 app [web.1]:npm错误! /app/.npm/_logs/2019-07-08T11_25_56_854Z-debug.log   2019-07-08T11:25:56.921581 + 00:00 heroku [web.1]:进程退出,状态为1

它表示正在尝试运行npm。但是该应用程序不使用npm。.希望你们能帮助我..

1 个答案:

答案 0 :(得分:0)

为了将融合反应模板部署到heroku,您需要完成几个额外的步骤,以确保正确安装了开发人员依赖项。

直接从其提供的Readme.txt文件中,以下是必要的步骤:

HEROKU笔记

如果您想将熔丝反应部署到heroku ,则可能会遇到问题,这是解决方案:

  1. 禁用生产模式以安装devDependencies:

    heroku config:set NPM_CONFIG_PRODUCTION=false

  2. 将您的分支推送到Heroku上的master分支:

    git push heroku <branch>:master

希望有帮助!