node.js - 将 MERN 部署到 Heroku 失败
问题描述
我正在尝试将此站点部署到 Heroku,但它给了我一个部署错误,这是我的 GitHub 代码:https ://github.com/hazem-kamel/Guestbook-MERN
日志:
Installing dependencies
Installing node modules (package.json + package-lock)
> nodemon@2.0.2 postinstall /tmp/build_d37d1bf6b721c463128a9d76ebc0c69a/node_modules/nodemon
> node bin/postinstall || exit 0
Love nodemon? You can now support the project via the open collective:
> https://opencollective.com/nodemon/donate
added 194 packages from 102 contributors and audited 195 packages in 4.934s
2 packages are looking for funding
run `npm fund` for details
found 2 low severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
-----> Build
Running build
> Backend@1.0.0 build /tmp/build_d37d1bf6b721c463128a9d76ebc0c69a
> run-p build:**
sh: 1: run-p: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! Backend@1.0.0 build: `run-p build:**`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the Backend@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! /tmp/npmcache.AjLZ0/_logs/2020-05-24T20_24_12_312Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
我尝试了几个代码,但也失败了:我正在使用 GitHub 代码和 Heroku 自动部署进行部署
解决方案
分别安装/添加到您的 npm/yarn:https ://www.npmjs.com/package/npm-run-all
此外,构建 Heroku 应用程序的首选方法是删除node_modules
文件夹并仅上传package.json
(包含要安装的依赖项!)。Heroku 在部署您的应用程序时会自动扫描package.json
文件并安装所有依赖项。
推荐阅读
- python - 列表中的唯一值
- python - 如何为 webhook 发送的消息添加反应?
- glm-math - 在 Cli/C++ 中将 GlmNet vec3 转换为 glm vec3 时遇到问题
- allure - Allure 2 报告生成 - 没有 Jenkins 或 Maven。是否有一套 API 和文档?
- date - Google Data Studio - 格式化日期 YEAR MONTH (YYYYMM) 不起作用
- vue.js - Vuetify Treeview 只允许子级可选
- python - 如何让 Python 使用正则表达式匹配“x264”
- javascript - 将水平滚动 div 调整为内容
- django - Django - 如何处理持续时间
- javascript - onchange 函数由于某种原因没有运行