Question

Running nested package.json commands

I am trying out digital ocean platform, have been using heroku; My project is a MEAN stack application. In heroku the build process worked like this; npm install the backend nodejs app; then that node app had a postinstall script that would run a required js script and also CD into my client directory and run the npm install for that directory, this client directory also had a post-install script to run ng build to build the angular repo for the nodejs to serve.

When I set up the repo to deploy to the DigitalOcean App Platform this nested npm install and commands do not seem to execute and build my frontend package.

I have been unable to find any questions or documents that reference this specific type of circumstance so I am hoping I am not asking an old question.


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.

alexdo
Site Moderator
Site Moderator badge
August 23, 2023

Heya,

The essential idea would be to adjust your build command in the App specification to something like this:

  1. npm install && npm run build && cd client && npm install && npm run build

This command will make sure that your server-side dependencies are installed and built before it navigates to your client directory to do the same.

You can specify your build command while creating and configuring your app in the app specification settings. If you’ve already created your app, you can adjust the build command by re-deploying your app with the updated configuration. You can find more information about configuring your app here.

Please keep in mind that the above command is just an example and might need to be adjusted according to your app’s specific requirements.

Hope that this helps!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.