reactjs - Heroku 无法解析模块 react-dom”
问题描述
我有一个使用 create-react-app 构建的应用程序,我正在努力将其部署到 Heroku。该应用程序使用 Express 后端和代理 React 服务器构建。Heroku 似乎无法找到 react-dom,即使它在我的 JSON 包中。构建日志如下:
> mern@1.0.0 build /tmp/build_2591a066d29a38493f0c2f48107a824f
> cd client && npm run build
> mern@0.1.0 build /tmp/build_2591a066d29a38493f0c2f48107a824f/client
> react-scripts build
Creating an optimized production build...
Failed to compile.
Module not found: Error: Can't resolve 'react-dom' in
'/tmp/build_2591a066d29a38493f0c2f48107a824f/client/src'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mern@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mern@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional
logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean
to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /app/.npm/_logs/2018-05-22T23_39_42_140Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mern@1.0.0 build: `cd client && npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mern@1.0.0 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! /app/.npm/_logs/2018-05-22T23_39_42_170Z-debug.log
! Push rejected, failed to compile React.js (create-react-app) multi
app.
! Push failed
客户端包 JSON:
{
"name": "mern",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:3001/",
"engines": {
"npm": "5.6.0",
"node": "8.11.1"
},
"dependencies": {
"axios": "^0.18.0",
"cheerio": "^1.0.0-rc.2",
"dotenv": "^5.0.1",
"material-ui": "^0.20.0",
"rc-checkbox": "^2.1.5",
"react": "^16.0.0",
"react-bootstrap": "^0.32.1",
"react-dom": "^16.3.2",
"react-facebook-auth": "^1.4.0",
"react-facebook-login": "^4.0.1",
"react-flexbox-grid": "^2.0.0",
"react-router-dom": "^4.2.2",
"react-scripts": "1.0.14",
"request": "^2.85.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
我试过的:
我已经在根目录和客户端文件夹中运行 npm update
我已经在客户端文件夹中安装了 react react-dom
不幸的是,在我对这个问题的所有研究中,我发现遇到这个问题的每个人都通过我尝试的两种解决方案之一解决了这个问题。都不适合我。
解决方案
推荐阅读
- javascript - wavesuerfer 如何解码音频文件?
- flask - 尝试将我的 WinCSP 连接到我的主机服务器,它给了我一个超时错误
- java - 使用 Freemarker 在 Netsuite 模板中将字符串编码为 Base64 格式
- postgresql - Postgres 函数返回没有目的地的错误
- material-ui - 水平方向的 Material-ui 折叠不能像预期的那样工作
- python - 使用 python 下载网格化 CHIRPS 数据集
- python - 使用 Python 将浮点数转储到 YAML 文件中的特定精度
- laravel - laravel 手动登录有效,但重定向到主页会话后不起作用
- java - 在流的 .collect 中指定集合大小会提高性能吗?
- python-3.x - Sys.argv 列表索引超出范围