webpacker won't compile when pushing to Heroku - ruby-on-rails

I've recently tried integrating react into my preexisting rails app by using the webpacker gem. When I try to push to heroku, I see the an error message like
remote: [1/5] Validating package.json...
remote: [2/5] Resolving packages...
remote: [3/5] Fetching packages...
remote: [4/5] Linking dependencies...
remote: [5/5] Building fresh packages...
remote: success Saved lockfile.
remote: Done in 0.09s.
remote: Compiling…
remote: Compilation failed:
remote: error Command "webpack" not found.
remote:
remote: yarn run v1.12.3
remote: info Visit https://yarnpkg.com/en/docs/cli/run for
documentation about this command.
remote:
remote:
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to spitball-production.
remote:
To https://git.heroku.com/spitball-production.git
! [remote rejected] master -> master (pre-receive hook declined)
My package.json looks like
{
"name": "Spitball",
"private": true,
"dependencies": {
},
"engines": {
"yarn": ">=0.25.2"
}
}
I've tried the solutions involving adding buildpacks and installing yarn and webpacker and so far nothing has helped. I'm expecting everything to push through no problem as all I've done is add the webpacker gem.

Did you try running
$ rails assets:precompile
in your terminal prior to pushing to Github then Heroku?
You have to compile all of your assets files prior to being built by Heroku.

Related

Pushing Rails app to heroku gives me Error: error:0308010C:digital envelope routines::unsupported

I have a Rails 7.x app I am trying to push to heroku and getting this error:
remote: Running: rake assets:precompile
remote: Compiling...
remote: Compilation failed:
remote: node:internal/crypto/hash:71
remote: this[kHandle] = new _Hash(algorithm, xofLen);
remote: ^
remote:
remote: Error: error:0308010C:digital envelope routines::unsupported
remote: at new Hash (node:internal/crypto/hash:71:19)
remote: at Object.createHash (node:crypto:133:10)
remote: at module.exports (/tmp/build_b1f32be4/node_modules/webpack/lib/util/createHash.js:135:53)
remote: at NormalModule._initBuildHash (/tmp/build_b1f32be4/node_modules/webpack/lib/NormalModule.js:417:16)
remote: at handleParseError (/tmp/build_b1f32be4/node_modules/webpack/lib/NormalModule.js:471:10)
remote: at /tmp/build_b1f32be4/node_modules/webpack/lib/NormalModule.js:503:5
remote: at /tmp/build_b1f32be4/node_modules/webpack/lib/NormalModule.js:358:12
remote: at /tmp/build_b1f32be4/node_modules/loader-runner/lib/LoaderRunner.js:373:3
remote: at iterateNormalLoaders (/tmp/build_b1f32be4/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
remote: at iterateNormalLoaders (/tmp/build_b1f32be4/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
remote: at /tmp/build_b1f32be4/node_modules/loader-runner/lib/LoaderRunner.js:236:3
remote: at context.callback (/tmp/build_b1f32be4/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
remote: at /tmp/build_b1f32be4/node_modules/babel-loader/lib/index.js:44:71 {
remote: opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
remote: library: 'digital envelope routines',
remote: reason: 'unsupported',
remote: code: 'ERR_OSSL_EVP_UNSUPPORTED'
remote: }
remote:
remote: Node.js v18.12.1
remote:
remote:
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
My node version locally is v18.12.1. I also saw a couple of issues where this might related to openssl. My openssl version local is OpenSSL 3.0.7 1 Nov 2022 (Library: OpenSSL 3.0.7 1 Nov 2022).
Any help appreciated!
I tried quite a few things in attempts to fix this issue, but I think what finally did it was adding
"engines": {
"node": "16.18.1"
}
...to my package.json file. Also I think the right way to do this is to go ahead and install the same version of node locally and re-run yarn install so your yarn.lock file is correct for that version.
Hope this helps someone!

Webpack / Yarn Error after Renaming Rails 6.1 App

I had a previously-functional app on Rails 6.1 that had successfully deployed to Heroku.
I (unfortunately) had to rename the app, which I did following these steps.
The app (post renaming) works perfectly on localhost.
I am 100% sure my code-to-Github relationship is working, because new commits show up on Github.
I have since deleted all git remotes as well as the Heroku app. I recreated a Heroku app and set it as a production remote.
I still get the following error every time I try to push to heroku:
remote: Compiling...
remote: Compilation failed:
remote: yarn run v1.22.4
remote: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
remote:
remote:
remote: error Command "webpack" not found.
remote:
remote:
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to the-failure-project.
remote:
To https://git.heroku.com/the-failure-project.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/the-failure-project.git'
I tried adding buildpacks, as recommended here:
heroku buildpacks:add --index 1 heroku/nodejs
heroku buildpacks:add --index 2 heroku/ruby
I'm stumped. Please help!

Can't push to heroku Rails 6. No command webpacker found/precompiling assets failed

When I run
git push heroku master
I get this:
3d03d9a9bed492eab33bdbd65f7.css
remote: I, [2020-11-22T00:08:54.351994 #1614] INFO -- : Writing /tmp/build_9cb71dd2/public/assets/rebel-99a5cf4009e103727878a62db3995432aec733d03d9a9bed492eab33bdbd65f7.css.gz
remote: Compiling...
remote: Compilation failed:
remote: yarn run v1.22.4
remote: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
remote:
remote:
remote: error Command "webpack" not found.
remote:
remote:
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
I've searched everywhere what the heck is going on? How do I fix this? Thank!

Webpack not found error deploying rails application on heroku

I was attempting to deploy my Ruby on Rails app on Heroku when I faced below issue. (Of course, I've created and deployed on my local machine successfully.)
error Command "webpack" not found.
I don't have a clue about how to even know deploying any apps on heroku.
Of course I tried many ways and there was this error still now.
I referenced the posts that prevent precompiling of assets from here and here.
I followed all steps of above posts and it looked like to fix errors I faced. But I just spent my time. I've add this line config.assets.initialize_on_precompile = false into config/application.rb and saw this GitHub issue because I found this article from Google with error commands. But these was not helpful.
I write my error:
remote: [4/4] Building fresh packages...
remote: Done in 1.77s.
remote: I, [2020-03-23T10:31:49.843316 #3000] INFO -- : Writing /tmp/build_0f0b4f66e4d0e7863926d7ab880dce89/public/assets/manifest-cadda289ef9c70eaa0879a36e6263cb33f7523a16b3ef862e0b8609cdc2bdab1.js
remote: I, [2020-03-23T10:31:49.844161 #3000] INFO -- : Writing /tmp/build_0f0b4f66e4d0e7863926d7ab880dce89/public/assets/manifest-cadda289ef9c70eaa0879a36e6263cb33f7523a16b3ef862e0b8609cdc2bdab1.js.gz
remote: I, [2020-03-23T10:31:49.844830 #3000] INFO -- : Writing /tmp/build_0f0b4f66e4d0e7863926d7ab880dce89/public/assets/application-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css
remote: I, [2020-03-23T10:31:49.845459 #3000] INFO -- : Writing /tmp/build_0f0b4f66e4d0e7863926d7ab880dce89/public/assets/application-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css.gz
remote: Compiling...
remote: Compilation failed:
remote: yarn run v1.22.4
remote: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
remote:
remote:
remote: error Command "webpack" not found.
remote:
remote:
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to evening-sierra-83681.
remote:
To https://git.heroku.com/evening-sierra-83681.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/evening-sierra-83681.git'

websocket-driver was not found on deploy

I am trying to update my Rails 5.2.1 app on Heroku and I've got this error.
remote: -----> Installing dependencies
remote: Installing node modules (yarn.lock)
remote: yarn install v1.17.2
remote: [1/4] Resolving packages...
remote: [2/4] Fetching packages...
remote: error An unexpected error occurred: "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.2.tgz: Request failed \"404 Not Found\"".
remote: info If you think this is a bug, please open a bug report with the information provided in "/tmp/build_053b37334aad96876abbe953fb52fde5/yarn-error.log".
remote: info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: Some possible problems:
remote:
remote: - Node version not specified in package.json
remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to myapp-production.
remote:
To https://git.heroku.com/lapenderie-production.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/myapp-production.git'
Here is my package.json:
{
"name": "kamelot",
"private": true,
"dependencies": {
"#rails/webpacker": "3.5",
"babel-preset-react": "^6.24.1",
"flatpickr": "^4.5.7",
"highcharts": "^7.1.1",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-color": "^2.17.3",
"react-dom": "^16.8.6",
"react_ujs": "^2.5.0",
"webpack-cli": "^3.3.4"
},
"devDependencies": {
"webpack-dev-server": "2.11.2"
}
}
I tried adding the node version but that didn't resolve the issue.
This used to work. How can I fix it?
I can't find this file "/tmp/build_545b56879454d397f9a53d8826eeeffb/yarn-error.log"
I did the following
cd tmp
Nothing like build_
For some reason version 0.7.2 of websocket-driver is not published on NPM, though it does exist on GitHub.
I suggest you upgrade to 0.7.3 (or whatever the latest version is when you read this) and redeploy:
yarn upgrade websocket-driver
git add yarn.lock
git commit -m 'Update dependencies'
git push heroku master
Best way for me:
delete package-lock.json
npm i

Resources