Playground npm-workspaces

Try different npm workspaces.

Quick start

npm install
npm run serve

access to http://localhost:3000 on browser.

Test

npm run test

Commands

workspace management

# add workspace
npm init -w workspace-xxx

# there is no command to remove a workspace
# remove the workspace directory and remove the workspace entry in the root package.json

dependency management

# add package-xxx to shared
npm install package-xxx -w shared
# the same command is used for workspace dependencies
npm install shared -w server

# remove package-xxx to shared
npm uninstall package-xxx -w shared

# remove package-xxx on all workspace
npm uninstall package-xxx -ws

run npm-script

# run a script-xxx of the root package.json
npm run script-xxx

# run a script-xxx of the shared package.json
npm run script-xxx -w shared
# or
cd shared
npm run script-xxx

# run a script-xxx of all workspace package.json
npm run script-xxx -ws

use npx

# run ts-node xxx.ts
npx -w shared ts-node xxx.ts