【发布时间】:2022-01-01 22:55:37
【问题描述】:
我正在为我的 MERN 应用程序开发一个 Node.js 服务器,并尝试在 Heroku 上部署该服务器。但是,在我按照 我的应用程序 Heroku 页面 上的常用命令并运行 git add .、git commit -am "Deploy commit" 和 git push heroku master 之后,它无法成功推送提交。
我在下面附上了我的 package.json 和日志文件。
我的 package.json 文件:
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "bower install && grunt build",
"start": "nodemon index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"bower": "^1.8.13",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.17.2",
"mongoose": "^6.1.2",
"multer": "^1.4.4",
"nodemon": "^2.0.15",
"path": "^0.12.7"
},
"engines": {
"node": "16.x",
"npm": "8.x"
}
}
我的日志文件:
-----> 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): 16.x
engines.npm (package.json): 8.x
Resolving node version 16.x...
Downloading and installing node 16.13.1...
Bootstrapping npm 8.x (replacing 8.1.2)...
npm 8.x installed
-----> Installing dependencies
Installing node modules
> server@1.0.0 postinstall
> node ./node_modules/bower/bin/bower install
bower ENOENT No bower.json present
npm ERR! code 1
npm ERR! path /tmp/build_c71e20e4
npm ERR! command failed
npm ERR! command sh -c node ./node_modules/bower/bin/bower install
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.nktzc/_logs/2022-01-01T10_48_31_122Z-debug-0.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
遇到上述错误后,我为我的 .bowerrc 文件添加了一个注册表,如下所示:
{
"registry": "https://registry.bower.io"
}
即使这并没有真正的帮助。 我该如何解决这个问题?
【问题讨论】:
-
注意:这不是 Git 问题。 Git 在这里只是充当信使,在您的系统和 Heroku 部署系统之间穿梭。 Heroku 拒绝了您部署代码的尝试。
标签: node.js heroku web-deployment