NPM
Workspace (i.e. nested package)
You can have a file structure like this:
So when you run npm i
in root directory, it install packages like this:
+-- node_modules
| `-- packages/a -> ../packages/a
+-- package-lock.json
+-- package.json
`-- packages
+-- a
| `-- package.json
Related command
# Init a workspace (NOTE: assume package.json already created)
npm init -w ./packages/a
# Install all packages defined in package.json of each workspaces
npm i
# Other command specific to a workspace, e.g. install, uninstall...etc
npm install abbrev -w a
# Run a command defined in workspace a
npm run test --workspace=a
# Run the commands defined in ALL workspaces
npm run test --workspaces