javascript - Node.js Heroku 部署 - 无法执行安装后脚本来安装 Bower

标签 javascript node.js heroku bower

将我的 Node.js MEAN 应用程序部署到 heroku 失败并出现以下错误。我无法弄清楚 bower 安装有什么问题......

这是错误信息:

2606 info postinstall App@1.0.0
2607 verbose unsafe-perm in lifecycle true
2608 info App@1.0.0 Failed to exec postinstall script
2609 error App@1.0.0 postinstall: `./node_modules/bower/bin/bower install`
2609 error Exit status 1
2610 error Failed at the App@1.0.0 postinstall script.
2610 error This is most likely a problem with the App package,
2610 error not with npm itself.
2610 error Tell the author that this fails on your system:
2610 error     ./node_modules/bower/bin/bower install
!     Push rejected, failed to compile Node.js app

这是我的 Bower.json

    {
  "name": "mean",
  "version": "1.0.0",
  "dependencies": {
    "bootstrap": "*",
    "angular": "*",
    "angular-resource": "*",
    "angular-cookies": "*",
    "angular-ui-utils": "*",
    "angular-bootstrap": "*",
    "json3": "*",
    "jquery": "*",
    "angular-ui-router": "*",
    "angular-animate": "*",
    "move.js": "git://github.com/visionmedia/move.js.git#~0.3.3",
    "animate.css": "*",
    "ngAnimate-animate.css": "*",
    "angularLocalStorage": "~0.1.7",
    "jquery-nicescroll": "*"
  },
  "resolutions": {
    "angular": "1.2.4"
  }
}

这是我的 Package.json

"scripts": {
    "start": "node node_modules/grunt-cli/bin/grunt",
    "test": "node node_modules/grunt-cli/bin/grunt test",
    "postinstall": "./node_modules/bower/bin/bower install"
},

最佳答案

我也经常遇到这个错误。由于 bower postinstall,每三次推送到 heroku 都会失败。

虽然这不是一个强大的修复程序,但我不完全理解它为什么会有所帮助!但这对我有帮助,所以希望能帮助其他人。

尽管/lib 文件夹正在添加到 .gitignore,但在部署 heroku 之前强制添加它

git add -f public/lib
git commit -m "force add bower libs"
git push heroku master

关于javascript - Node.js Heroku 部署 - 无法执行安装后脚本来安装 Bower,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20826580/

相关文章:

javascript - 如何使用 jQuery 切换标签样式

javascript - 为 Node js 定义模式路由

javascript - 当 promise 得到解决时,异步函数不会返回

heroku - 当试图在Heroku上建立索引时,Elasticsearch返回504

javascript - 将鼠标快速移入/移出容器会导致不需要的 jQuery 动画

JavaScript 事件,例如 onclick 和 onload

javascript - 获取 OSRM 路由的 JSON

javascript - 将标志从 Node/Express 应用程序传递给 Python 脚本

python - 仅针对经过身份验证的用户的 Django 缓存

Heroku - Express 应用程序 - 错误 : spawn compass ENOENT