Report this

What is the reason for this report?

Building services with Node JS on App Platform

Posted on March 10, 2021

I am using webpack to compile my node/expressjs application. When running the npm run build (which uses webpack), I keep getting the error ‘webpack not found’, even though I have all the webpack and webpack-cli dependency in my package.json

BUILD LOGS

backend                         | 18:59:31 > backend@1.0.0 build /workspace
backend                         | 18:59:31 > webpack
backend                         | 18:59:31 
backend                         | 18:59:31 sh: 1: webpack: not found
backend                         | 18:59:31 npm ERR! code ELIFECYCLE
backend                         | 18:59:31 npm ERR! syscall spawn
backend                         | 18:59:31 npm ERR! file sh
backend                         | 18:59:31 npm ERR! errno ENOENT
backend                         | 18:59:31 npm ERR! backend@1.0.0 build: `webpack`
backend                         | 18:59:31 npm ERR! spawn ENOENT
backend                         | 18:59:31 npm ERR! 
backend                         | 18:59:31 npm ERR! Failed at the backend@1.0.0 build script.
backend                         | 18:59:31 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
backend                         | 18:59:31 
backend                         | 18:59:31 npm ERR! A complete log of this run can be found in:
backend                         | 18:59:31 npm ERR!     /home/apps/.npm/_logs/2021-03-10T18_59_31_786Z-debug.log
backend                         | 18:59:31 building: exit status 1
backend                         | 18:59:31 ERROR: failed to build: exit status 1


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I used this command in the build script to ensure DO installs the devDependecy

npm install --only=dev && npm run build && npm prune --production

Further explanation can be found at this link

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.