Webpack not found when app deployed to Heroku

I'm getting the error sh: 1: webpack: not found when the app is deployed to production. I've tried moving all the dependencies related to webpack from the devDependency list to the dependency list in the package.json file to avail. The Heroku error log can be seen here for greater insight. What steps could be taken to solve this issue?

Heroku错误日志


You are assuming 'webpack' is installed as a global package in your heroku environment.

Run webpack directly from your node_modules to avoid having to install it globally, like so...

package.json:

{
  ...
  "scripts": {
    "build": "node node_modules/webpack/bin/webpack.js --display-error-details",
    ...
  }
  ...
}

Can you try running npm run build on postinstall? This works for me.

package.json

{
  ...
  "scripts": {
    "start": "node server.js",
    "postinstall": "npm run build",
    ...
  }
  ...
}
链接地址: http://www.djcxy.com/p/85106.html

上一篇: 对Heroku的Nodejs应用程序部署失败

下一篇: 应用程序部署到Heroku时未找到Webpack