Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku build failed due to webpack CLI not installed - Rails 6

I have successfully deployed my app to production in Heroku in the past but this is the first time I have moved my rails assets to be delivered by webpack. Everything works great in development but when I try to deploy to Heroku I get the following error message:

remote:        [4/4] Building fresh packages...
remote:        Done in 39.56s.
remote:        Compiling...
remote:        Compilation failed:
remote:        CLI for webpack must be installed.
remote:          webpack-cli (https://github.com/webpack/webpack-cli)
remote:        
remote:        We will use "yarn" to install the CLI via "yarn add -D webpack-cli".
remote:        Do you want to install 'webpack-cli' (yes/no): 
remote: 
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed

I have webpack-cli installed in my package so I am not sure why it is failing on the deployment to Heroku. I also have the nodejs heroku buildpack configured to build prior to the ruby heroku buildpack on the server.

I have ran yarn add -D webpack-cli on my local machine to ensure webpack-cli is installed.

Below is my package.json file:

{
  "name": "appex",
  "private": true,
  "dependencies": {
    "@popperjs/core": "^2.9.2",
    "@rails/actioncable": "^6.0.0",
    "@rails/activestorage": "^6.0.0",
    "@rails/ujs": "^6.0.0",
    "@rails/webpacker": "5.2.1",
    "bootstrap": "^5.0.1",
    "bootstrap-icons": "^1.5.0",
    "file-loader": "^6.2.0",
    "jquery": "^3.6.0",
    "sass-loader": "^12.0.0",
    "turbolinks": "^5.2.0"
  },
  "version": "0.1.0",
  "devDependencies": {
    "@babel/core": "^7.14.3",
    "@babel/preset-env": "^7.14.2",
    "babel-loader": "^8.2.2",
    "css-loader": "^5.2.6",
    "resolve-url-loader": "^4.0.0",
    "style-loader": "^2.0.0",
    "webpack": "^5.37.1",
    "webpack-cli": "^4.7.2",
    "webpack-dev-server": "^3.11.2"
  }
}

Rails version 6.0.3.4 ruby version 2.6.3

Any help is appreciated!

like image 874
Splohr Avatar asked Jan 17 '26 12:01

Splohr


1 Answers

Here is something maybe helpful https://github.com/webpack/webpack/issues/7197

like image 181
Shaher Shamroukh Avatar answered Jan 20 '26 03:01

Shaher Shamroukh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!