Run App Specific Commands in a Monorepo

Share this video with your friends

Send Tweet

To run specific commands inside a monorepo we have to type npm run then the name of the command, build. We then add the flag -w for watch mode and specify which package we want to run the build command. In this case, it’s going to be the utils package.

The full command will look like, npm run build -2 @monorepo/utils.

If you want to run all of the commands, you'll need to add the -ws flag.

The full command for running all of our build commands will look like, npm run build -ws.

Rob
~ a year ago

Hi Alejandro, first up, great course, really enjoying it

For me, running node v18.13.0 and npm 8.19.3 (Apr 2023) to get this working I had to run the following command ...

npm init -w name-of-workspace

I then went thru the interactive prompts to setup up the package.json file.

Then once that was done the npm run command would work as you describe here.

Running the npm init -w command seemed to respect and retain exiting content of pre-existing package.json files but of course was especially useful when there we no existing package.json.

Apologies, if you mention this elsewhere (I am racing thru the course and coding as I go!)

Thank you again for a great course! Feel free to reach out to me if you need any clarification on this feedback. Rob Kielty

Alejandro Ñáñezinstructor
~ a year ago

Hey Rob, thanks for reaching out!

Do you happen to have a repo that I can take a look at? I’m happy to help!

And I’m glad you like the course so far! ❤️