Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

pepegarcia's avatar

Error Deploying with webpack on Heroku

Hi, im trying to deploy a Laravel 5.4 application on heroku and everything works fine except when assets are about to compile running 'npm run prod' configured on packaje.json with the postinstall key to run automatically.

Here is my webpack.mix.js file:

mix.js('resources/assets/js/app.js', 'public/js') .sass('resources/assets/sass/app.scss', 'public/css');

mix.copy('./node_modules/bootstrap-switch/dist/js/bootstrap-switch.js', 'public/js'); mix.copy('./node_modules/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.css', 'public/css'); mix.copy('./node_modules/animate.css/animate.css', 'public/css');

mix.copy('./node_modules/sweetalert/dist/sweetalert.css', 'public/css'); mix.copy('./node_modules/sweetalert/dist/sweetalert.min.js', 'public/js');

And here is the error that i'm getting on heroku;

@ production /tmp/build_e047d1635df922533f1138aaed49ec27 remote: > cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js remote: remote: 95% emitting DONE Compiled successfully in 20810ms7:43:16 PM remote: remote: fs.js:907 remote: return binding.stat(pathModule._makeLong(path)); remote: ^ remote: remote: Error: ENOENT: no such file or directory, stat '/tmp/build_e047d1635df922533f1138aaed49ec27/node_modules/bootstrap-switch/dist/js/bootstrap-switch.js' remote: at Object.fs.statSync (fs.js:907:18)

0 likes
1 reply
pepegarcia's avatar
pepegarcia
OP
Best Answer
Level 1

Fixed!

NPM dependencies were installed without the --save flag so i noticed that they weren't on the package.json file so I just add them and whoops! Everything is working fine.

1 like

Please or to participate in this conversation.