Question

Building services with Node JS on App Platform

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

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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