I added a the heroku/nodejs buildpack to my Symfony heroku app, and I am able to install my yarn dependencies.
However I am not able to run
$ yarn run encore production
I always have the same error Command "encore" not found
whether I run the command in composer.json :
// composer.json
"compile": [
"node_modules/.bin/encore production",
[•••]
or in package.json
//package.json
"scripts": {
"heroku-postbuild" : "yarn run encore production"
[•••]
In your package.json root file :
"scripts": { ... "heroku-postbuild" : "node_modules/.bin/encore production" }
It will run your webpack encore and running your others npm modules.
To anyone coming here, you'll first need to add the node buildpack to your app, as per this question.
Make sure to add the node buildpack before the php one.
Then, add "node_modules/.bin/encore production"
to your compile (as shown in the question).
Finally, as written in comment, don't forget to change webpack dependencies from devDependencies
to dependencies
in your package.json
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With