nodejs-commands.md

April 17, 2026 · View on GitHub

NodeJS Commands

Notes:

  • npm install --save (-S) and npm install --save-dev (-D) flags are the default behaviour since npm v5 — the flags are still valid but optional.
  • Prefer npx <package> over global (-g) installs for one-off CLI tools to always use the latest version.
  • Use the node: protocol prefix for built-in module imports in modern Node.js: import { readFile } from 'node:fs/promises'.
Sl.No.CommandsDescription
01.npm install node@22Install Node.js v22 (current LTS as of 2026). Use nvm / fnm for version management on your machine.
02.npm initCreates package.json interactively
03.npm init -yCreates package.json with defaults (skip prompts)
04.npm installInstall all dependencies listed in package.json into node_modules
05.npm ciClean install from package-lock.json (faster, deterministic – use in CI/CD pipelines)
06.npm install -g live-serverInstall live-server globally
07.npm install -g grunt-cliInstall Grunt CLI globally
08.live-serverStart a local dev HTTP server with live reload
09.npm install expressInstall express into local project (--save is default since npm v5)
10.npm install corsCross Origin Resource Sharing – allows API access from other domains
11.npm install express-sessionInstall express-session
12.npm install mongooseInstall Mongoose (MongoDB ODM)
13.npm install wsInstall WebSocket library
14.npm install socket.ioWebSocket abstraction with fallbacks
15.npm install underscoreUtility library (consider lodash or native ES2024 alternatives)
16.npm uninstall underscoreRemove a package
17.npm install --save-dev mochaJavaScript unit-testing framework
18.npx mochaRun Mocha tests via npx (no global install needed)
19.npm install --save-dev nockHTTP server mocking for tests
20.npm install --save-dev rewireDependency injection for tests
21.npm install --save-dev sinonMocks, stubs and spies for tests
22.npm install --save-dev supertestHTTP assertion library for integration tests
23.npm install --save-dev cheerioServer-side jQuery-like HTML parsing
24.npm install --save-dev c8Native V8 code-coverage tool (replaces the deprecated istanbul/nyc)
25.npx c8 mochaRun Mocha with V8 coverage report
26.npm install --save-dev eslintJavaScript/TypeScript linter (replaces the legacy jshint)
27.npx eslint --initInteractive ESLint configuration wizard
28.npm install -g typescriptInstall TypeScript compiler globally
29.npm install -g webpack-cliInstall Webpack CLI globally
30.npx webpackRun Webpack via npx
31.npm install -g sassInstall Dart Sass (the current implementation – Ruby Sass is end-of-life)
32.sass --watch src/styles:dist/cssWatch and compile Sass to CSS
33.sass --style=compressed input.scss output.cssCompile and minify a Sass file
34.gulp developStart dev server (Gulp task)
35.gulp buildClean and minify into a single file
36.gulp watchWatch for file changes
37.gulp test:tddRun unit tests in TDD mode
38.npm startRun the start script defined in package.json
39.node app.jsRun app.js on Node.js
40.node --watch app.jsRun app.js and auto-restart on file changes (built-in since Node.js 18, replaces nodemon for basic use)
41.node --inspect app.jsStart Node.js with Chrome DevTools debugger enabled
42.node --inspect-brk app.jsStart with debugger and break on first line
43.node -vPrint Node.js version
44.npm -vPrint npm version
45.tsc -vPrint TypeScript compiler version
46.git versionPrint Git version
47.webpack -vPrint Webpack version
48.npm -lDisplay full npm usage info
49.npm config listList npm configuration
50.npm config rm proxyRemove proxy setting
51.npm config rm https-proxyRemove HTTPS proxy setting
52.npm cache clean --forceClear the npm cache (--force required since npm v5)
53.npm auditScan installed packages for known security vulnerabilities
54.npm audit fixAutomatically fix vulnerabilities where possible
55.npm outdatedList packages that have newer versions available
56.npm updateUpdate all packages to their latest compatible versions
57.npm run <script>Run a script defined in the scripts field of package.json
58.npm packCreate a tarball of the package (useful before publishing)
59.npm publishPublish the package to the npm registry
60.npm linkCreate a symlink in the global folder
61.npm link <package>Link-install a package from another local directory
62.npx <package>Execute a package binary without installing it globally
63.corepack enableEnable Corepack (built-in Node.js 16.9+ tool that manages Yarn and pnpm versions)
64.ng add @angular/materialAdd Angular Material to an Angular project
65.npm install rxjsReactive Extensions Library for JavaScript (current: v7.x)
66.npm install jsonwebtokenJSON Web Token implementation
67.npm install dotenvLoad environment variables from a .env file
68.npm install helmetSecure Express apps by setting various HTTP headers
69.npm install --save-dev jestJavaScript testing framework with built-in coverage
70.npx jest --coverageRun Jest tests with coverage report
71.npm install --save-dev @types/nodeTypeScript type definitions for Node.js
72.npm install grunt-contrib-watch --save-devGrunt plugin to watch files for changes