npm & Nx Command Reference

Quick reference for package management and monorepo commands in EBRAINS UI Ecosystem.

Quick Links

Overview

The EBRAINS UI Ecosystem uses:

  • Nx - Smart monorepo tool for building and testing applications
  • npm - Package manager for installing and managing dependencies

Together, they provide a powerful development environment for building EBRAINS applications.

Getting Started

If you’re new to the EBRAINS UI Ecosystem:

  1. Build Your First App Tutorial - Complete walkthrough
  2. Install dependencies: npm install
  3. Generate app: npx nx generate @nx/react:application my-app
  4. Serve app: nx serve my-app

Quick Examples

Create and Run New App

Install and Use Package

Run Quality Checks

Common Commands Comparison

TaskNx Commandnpm Command
Install dependencies-npm install
Generate appnpx nx generate @nx/react:application my-app-
Serve appnx serve my-appnpm run serve
Build appnx build my-appnpm run build
Test appnx test my-appnpm test
Lint appnx lint my-appnpm run lint
Add package-npm install package-name
Update packages-npm update
Run script-npm run script-name

Nx Quick Reference

Generate

Develop

Monorepo

npm Quick Reference

Install

Manage

Scripts

Typical Workflow

Day 1: Setup

Daily Development

Adding New Dependency

Running Quality Checks

Common Ports

ApplicationPort
React apps4200, 4300, 4400
Handbook (Hugo)1313
Custom portUse --port=XXXX

Troubleshooting

Command Not Found: nx

Port Already in Use

Module Not Found

Build Fails

Best Practices

Do

  • Use npx nx for Nx commands
  • Commit package-lock.json
  • Run npm audit regularly
  • Use Nx generators for new projects
  • Keep dependencies updated
  • Use nx affected in CI/CD
  • Clear cache when debugging (nx reset)

Don’t

  • Don’t commit node_modules/
  • Don’t manually edit package-lock.json
  • Don’t skip migrations after Nx updates
  • Don’t ignore security warnings
  • Don’t use sudo npm install
  • Don’t create projects manually (use generators)

External Resources