【问题标题】:Unable to git push my node.js server to Heroku, says no bower.json present无法将我的 node.js 服务器 git 推送到 Heroku,说没有 bower.json
【发布时间】: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


【解决方案1】:

经过一番研究,我得到了构建成功的消息。以下是我为使其正常工作所做的工作:

  1. 所以我做的第一件事就是npm install bower-json
  2. 之后,我使用bower init 并初始化了应用程序。
  3. 然后我删除了package.json中scripts下的build
  4. 之后,我又去找了另一个git addgit commitgit push heroku master

这个过程使我的构建成功!

【讨论】:

    猜你喜欢
    • 2017-01-25
    • 1970-01-01
    • 1970-01-01
    • 2013-03-10
    • 2015-03-14
    • 2014-08-05
    • 1970-01-01
    • 2015-05-23
    • 2020-06-26
    相关资源
    最近更新 更多