MERN 堆栈 - 在 Heroku 上部署时收到错误
MERN Stack - Error Received while deploying on Heroku
我开发了一个 MERN 堆栈应用程序并创建了 React 构建。在地址
部署之前构建工作正常
http://localhost:3304/
然而,当我尝试部署它时,出现以下错误
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 14.17.0
engines.npm (package.json): unspecified (use default)
Resolving node version 14.17.0...
Downloading and installing node 14.17.0...
Using default npm version: 6.14.13
-----> Installing dependencies
Installing node modules
added 79 packages in 1.784s
-----> Build
Running heroku-postbuild
> backend@1.0.0 heroku-postbuild /tmp/build_b4cd03b2
> NPM_CONFIG_PRODUCTION=false npm install npm && run ../build
+ npm@7.15.1
added 254 packages from 921 contributors and audited 333 packages in 8.161s
13 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
sh: 1: run: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! backend@1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install npm && run ../build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the backend@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.AcJvb/_logs/2021-06-02T08_22_03_806Z-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
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
package.json 文件添加了以下行。作为客户端代码的构建和作为服务器代码的后端放在旁边的两个目录中。
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install npm && run ../build"
},
快速提问,您是否尝试将后端和前端与 heroku 一起部署?
过去我用 heroku 部署了我的后端,用 netlify 部署了我的前端
我开发了一个 MERN 堆栈应用程序并创建了 React 构建。在地址
部署之前构建工作正常http://localhost:3304/
然而,当我尝试部署它时,出现以下错误
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 14.17.0
engines.npm (package.json): unspecified (use default)
Resolving node version 14.17.0...
Downloading and installing node 14.17.0...
Using default npm version: 6.14.13
-----> Installing dependencies
Installing node modules
added 79 packages in 1.784s
-----> Build
Running heroku-postbuild
> backend@1.0.0 heroku-postbuild /tmp/build_b4cd03b2
> NPM_CONFIG_PRODUCTION=false npm install npm && run ../build
+ npm@7.15.1
added 254 packages from 921 contributors and audited 333 packages in 8.161s
13 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
sh: 1: run: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! backend@1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install npm && run ../build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the backend@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.AcJvb/_logs/2021-06-02T08_22_03_806Z-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
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
package.json 文件添加了以下行。作为客户端代码的构建和作为服务器代码的后端放在旁边的两个目录中。
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install npm && run ../build"
},
快速提问,您是否尝试将后端和前端与 heroku 一起部署?
过去我用 heroku 部署了我的后端,用 netlify 部署了我的前端