【问题标题】:Build of Parcel React App fails on Heroku在 Heroku 上构建 Parcel React 应用程序失败
【发布时间】:2021-11-16 17:30:20
【问题描述】:

我正在尝试部署一个 parcel react 应用程序,而 Heroku 上没有后端。构建不断失败,我已经尝试了互联网上的所有内容。这是脚本和依赖项。这是错误。

错误:

    lscpu: failed to determine number of CPUs: /sys/devices/system/cpu/possible: No such file or directory

/tmp/build_c7ac30db/src/components/App.js:14:19: Cannot resolve dependency '../pages/a00auth/A01SignUp.js' at '/tmp/build_c7ac30db/src/pages/a00auth/A01SignUp.js'
         12 |
         13 | import errorReporting from '../exceptions/errorReporting';
       > 14 | import SignUp from '../pages/a00auth/A01SignUp.js';
            |                   ^
         15 | import SignIn from '../pages/a00auth/A02SignIn';
         16 | import OfflineMessage from '../components/OfflineMessage';
         17 |
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! teziagents@1.0.0 heroku-postbuild: `parcel build ./src/index.html`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the teziagents@1.0.0 heroku-postbuild 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!     /tmp/npmcache.05UZK/_logs/2021-09-23T09_57_29_536Z-debug.log
-----> Build failed

脚本:

"scripts": {
    "start": "parcel ./src/index.html",
    "build": "parcel build ./src/index.html",
    "postbuild": "workbox generateSW",
    "predeploy": "rm -rf dist && npm run build",
    "deploy": "gh-pages -d dist"
  },

依赖关系:

"dependencies": {
    "@reach/router": "^1.3.4",
    "grommet": "^2.17.1",
    "grommet-controls": "^3.0.1",
    "grommet-icons": "^4.5.0",
    "parcel-bundler": "^1.12.5",
    "@parcel/transformer-webmanifest": "^2.0.0-beta.2",
    "pouchdb": "^7.2.2",
    "pouchdb-authentication": "^1.1.3",
    "pouchdb-browser": "^7.2.2",
    "pouchdb-core": "^7.2.2",
    "pouchdb-find": "^7.2.2",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-hook-form": "^7.7.1",
    "styled-components": "^5.2.3",
    "tslib": "^2.2.0"
  },

非常感谢这里的任何帮助。一个月以来我一直在为此烦恼????

【问题讨论】:

    标签: reactjs heroku parceljs


    【解决方案1】:

    Heroku 是为后端应用程序而设计的。它无法构建您的应用程序。

    因此,如果您想开发您的 react 应用程序,则必须使用(已构建应用程序的)nodejs 包装器,该包装器更复杂,但运行速度也不够快。

    在这种情况下,如果你想部署一个几乎不需要任何配置的快速反应应用程序,你可以使用:

    或者如果你可以在最后构建并上传 dist 文件夹,你也可以使用:

    【讨论】:

    • 感谢您的回复。我在 netlify 上收到以下错误。同样的错误也出现在heroku上。该文件夹位于我的本地计算机上。我错过了什么? ``` /opt/build/repo/src/components/App.js:14:19: 无法解析依赖 '../pages/a00auth/A01SignUp.js' 在 '/opt/build/repo/src/pages/ a00auth/A01SignUp.js' ```
    • 你的开发依赖中有workbox-cli吗?
    • 不,它没有任何依赖关系。
    猜你喜欢
    • 1970-01-01
    • 2022-06-14
    • 2018-09-01
    • 2017-08-21
    • 2022-10-14
    • 2022-08-10
    • 2015-05-08
    • 2019-10-28
    • 2022-09-28
    相关资源
    最近更新 更多