【问题标题】:Heroku - error running browserify on Node deploymentHeroku - 在节点部署上运行 browserify 时出错
【发布时间】:2017-08-23 18:28:28
【问题描述】:

我正在尝试将 Node 应用程序部署到 Heroku,但在部署应用程序时成功运行 browserify 时遇到问题。

当我在本地运行时,我使用npm run bundle 浏览我的脚本,就像这样(来自package.json):

"bundle": "./node_modules/browserify/bin/cmd.js build/main.js -o public/scripts/bundle.js

浏览build/main.js 中的脚本并将其放入public/scripts/bundle.js。

为了部署到 Heroku,我添加了

"postinstall": "npm run bundle"

但是,当我部署时,我收到以下错误:

Error: ENOENT: no such file or directory, open 'public/scripts/bundle.js.tmp-browserify-59309133185877094263'

嗯,没错,那个文件不应该存在......但是。当我在本地运行 npm run bundle 时,我确实看到该文件短暂地出现了,但很快它就被删除了,我留下了一个很好的更新 bundle.js。

我阅读了 Heroku 的相关文档,但我很恼火……谁能说明如何解决这个问题?

供参考,下面是我package.json的相关部分:

"scripts": {
    "bundle": "./node_modules/browserify/bin/cmd.js build/main.js -o public/scripts/bundle.js",
    "postinstall": "npm run bundle"
},
"dependencies": {
    "body-parser": "^1.17.1",
    "browserify": "^14.1.0",
    "ejs": "^2.5.6",
    "express": "^4.15.2",
    "jquery": "^3.2.1",
    "path": "^0.12.7",
    "superagent": "^3.5.2"
},
"devDependencies": {},
"engines": {
    "node": "6.8.1",
    "npm": "4.0.5"
}

【问题讨论】:

    标签: node.js heroku browserify


    【解决方案1】:

    解决了!我的全局 gitinore 配置中包含了 bundle.js。只需要把它拿出来,很好!

    【讨论】:

      猜你喜欢
      • 2021-12-26
      • 2016-10-12
      • 2018-01-04
      • 1970-01-01
      • 2020-09-11
      • 1970-01-01
      • 2014-07-31
      • 2022-11-08
      • 2016-04-09
      相关资源
      最近更新 更多