Skip to main content
Version: Current

Some useful scripts

This page looks at the npm commands for building a project.

  1. Bootstrap the packages. This installs all the packages' dependencies and links any cross-dependencies.

You must do this at least once to get the top-level client dependencies in place.

From your client folder:

npm run bootstrap

This is a shortcut for:

npm run husky:install && npx lerna bootstrap --hoist

When you run this command, it will:

  • run husky:install (which installs git command hooks)
  • npm install all external dependencies of each package
  • symlink together all Lerna packages that are dependencies of each other
  • npm run prepublish in all bootstrapped packages (unless --ignore-prepublish is passed)
  • npm run prepare in all bootstrapped packages

Passing --ignore-scripts to the bootstrap command speeds up the process, as it skips any lifecycle scripts that are normally run (prepare, etc) in bootstrapped packages.

If you prefer to use this shortcut, run this from your client folder:

npm run bootstrap:ignore-scripts

Scripts can call other scripts.
husky:install called by bootstrap above for example is just another script.
Remember, as discussed previously, you can see all available scripts and their definitions in the package.json file.

  1. Start the web client (watch mode)

To start the web client in watch mode:

npm run client:web

This command cleans and bootstraps all the dependencies by topological order and starts the application.

If you get Error: Cannot find module 'rimraf' you need to remember to run bootstrap at least once before using the npm run client:web shortcut.

Build the web application

From inside the web application's folder (e.g. client/web/), run this command:

npm run build

This builds your app using webpack. It generates the bundle in the dist folder.

It is a shortcut for:

cross-env NODE_ENV=production AUTO_CONNECT=true webpack

Lerna add dependency examples

Do not use npm to install or manage dependencies, because it causes problems with lerna. This is because lerna can only process one dependency at a time, so there is no command like npm i package-a package-b package-c.

# Install rxjs in all modules
lerna add rxjs

# Install rxjs in all modules in devDependencies
lerna add rxjs --dev

# Install rxjs in @{{kebabCase pkgScope}}/{{kebabCase pkgName}}-web-client only
lerna add rxjs --scope=@{{kebabCase pkgScope}}/{{kebabCase pkgName}}-web-client

List produced packages

npm run list

Prepare packages

npm run prepare

Manual reset

If you have build issues and you want to reset, use the following script to remove the node_modules directory from all the packages (not the root).

npm run clean

After this, you should (must) run bootstrap again from your client folder.

npm run bootstrap

Clean the dist directory in all packages.

npm run clean:dist