How to run npm install on all projects in Lerna

Overview

An operation that manages separate projects such as server + front in one repository is called monorepo (monolipo?). This time, using the monorepo optimization tool Lerna, we will execute npm install to the project of all the projects in operation at once. In my case, I needed it when turning with CI.

Conclusion

Use the lerna exec command.

For a directory structure like the one below, running lerna exec npm install in the root directory will run npm install on both front and server.

├──packages
│    ├── front
│    │   ├── package-lock.json
│    │   ├── package.json
│    │   ...
│    └── server
│        ├── package-lock.json
│        ├── package.json
│        ...
├── package-lock.json
├── package.json
├── lerna.json
...

A little more detail ...

There are the following two commands for executing commands in each package provided by lerna.

Also, both commands have quite common options.

Finally

I couldn't find much when I looked up the article, but when I saw the official README, it was easy to solve. Basically, I write it in npm script, so I don't care from the middle, but it is very important to know the types of commands and options just because I can do this.

Recommended Posts

How to run npm install on all projects in Lerna
[Ruby on Rails] How to install Bootstrap in Rails
How to run JUnit in Eclipse
How to run Ant in Gradle
How to install ImageMagick on Windows 10
How to run JavaFX on Docker
How to install Bootstrap in Ruby
How to install MariaDB 10.4 on CentOS 8
How to install WildFly on Ubuntu 18.04
How to install Swiper in Rails
How to install Eclipse (Photon) on Mac
How to install production Metabase on Ubuntu
How to install beta php8.0 on CentOS8
How to install kafkacat on Amazon Linux2
How to install network drivers on standalone Ubuntu
How to install Titan2D (v4.2.0) in virtual environment
How to run a djUnit task in Ant
How to install multiple JDKs on Ubuntu 18.04 LTS
How to Install Oracle JDK 1.8 in Ubuntu 18.04 LTS?
How to run NullpoMino 7.5.0 on Ubuntu 20.04.1 64bit version
Notes on how to write comments in English
How to install Docker
How to install docker-machine
How to install MySQL
How to install ngrok
How to clear all data in a particular table
How to install Ruby on an EC2 instance on AWS
[Ruby on Rails] How to write enum in Japanese
How to run javafx with Raspberry Pi Posted on 2020/07/12
[Ruby On Rails] How to reset DB in Heroku
How to Git manage Java EE projects in Eclipse
How to run Java EE Tutial on github on Eclipse
Install MySQL 5.6 on CentOS6 [How to specify the version]
Notes on how to use regular expressions in Java
[Rails] How to install devise
How to deploy on heroku
How to Install Elixir and Phoenix Framework on Ubuntu 20.04 LTS
How to install Boots Faces
How to display a graph in Ruby on Rails (LazyHighChart)
How to install JDK 8 on Windows without using the installer
How to install java9 on elementaryOS Freya or Ubuntu 14.04 LTS
Super easy in 2 steps! How to install devise! !! (rails 5 version)
How to switch Java in the OpenJDK era on Mac
How to install GNOME as a desktop environment on CentOS 7
How to install Web application for each language in Nginx
How to run React and Rails on the same server
How to install PHP 7.4 and SQL Server drivers in CentOS 7.7
[Rails] How to install simple_calendar
[Rails] How to install reCAPTCHA
How to install JDK8-10 (Mac)
How to install and use Composer on an ECS instance on Ubuntu 16.04
How to run a mock server on Swagger-ui using stoplight/prism (using AWS/EC2/Docker)
[Webpacker] Summary of how to install Bootstrap and jQuery in Rails 6.0
How to automatically operate a screen created in Java on Windows
How to install and configure the monitoring tool "Graphite" on Ubuntu
How to run a job with docker login in AWS batch
How to install the language used in Ubuntu and how to build the environment
How to install Adopt OpenJDK on Debian, Ubuntu with apt (-get)
[RubyOnRails] How to implement pull-down in form_with based on table data
Install Ubuntu20.04 on RaspberryPi 4 and build Kubernetes to run the container
Steps to install Maven on Mac and use it in Eclipse