A simple Bash script that starts multiple Node.js projects from a single command.
This repository is useful when working with several related applications, such as microfrontends, that need to run at the same time during local development.
- Runs multiple projects with a single script.
- Supports absolute or relative project paths.
- Allows projects to be enabled or disabled easily.
- Optionally runs
npm installbefore starting each project. - Starts every project in the background.
- Skips invalid project paths without stopping the entire script.
Before running the script, make sure you have the following tools installed:
- Node.js
- npm
- Bash
On Windows, the script can be executed using Git Bash.
multi-project-runner/
├── run-projects.sh
└── README.md
Open run-projects.sh and update the base path where your projects are located:
path="/c/Projects/"Use forward slashes (/), even when running the script on Windows through Git Bash.
Then configure the projects you want to start:
projects=(
"${path}ref-common-mf"
"${path}ref-store-mf"
"${path}ref-search-code-mf"
)To disable a project temporarily, comment out its line:
projects=(
#"${path}ref-host-mf"
"${path}ref-common-mf"
)The INSTALL_DEPS variable controls whether npm install is executed before npm start.
INSTALL_DEPS=falseAvailable values:
true: runsnpm installbeforenpm start.false: runs onlynpm start.
For daily development, keeping this option set to false is usually faster.
Give the script execution permission:
chmod +x run-projects.shRun the script:
./run-projects.shYou can also execute it directly with Bash:
bash run-projects.shThe script iterates through the configured project list.
For each project, it:
- Verifies that the project directory exists.
- Changes the current directory to the project folder.
- Optionally runs
npm install. - Runs
npm startas a background process. - Continues with the next configured project.
The script uses the & operator to start each application in the background:
npm start &At the end, the wait command keeps the script active until all background processes have finished.
📁 Project: /c/Project/ref-common-mf
▶️ Running npm start...
📁 Project: /c/Project/ref-store-mf
▶️ Running npm start...
🔥 All npm start commands have been launched.
If a configured directory does not exist, the script displays a warning and continues:
⚠️ Path does not exist: /c/Project/example-project
Press:
Ctrl + C
Depending on the terminal and operating system, some background Node.js processes may remain active. If necessary, stop them manually from the operating system's process manager.
- Every project must contain a valid
package.json. - Every project must define a
startscript. - Projects may use different ports.
- Make sure the configured applications do not attempt to use the same port.
- The script uses npm, but it can be adapted to work with pnpm or Yarn.
This project is intended for internal development and automation purposes. Add the license that best matches your repository requirements. :::