DEV Community

Cover image for Command-Line Magic: Essential JavaScript CLI Commands
Mohamed El Laithy
Mohamed El Laithy

Posted on

Command-Line Magic: Essential JavaScript CLI Commands

1. Node.js CLI Commands

Overview: Node.js is a JavaScript runtime that allows running JavaScript outside the browser, mainly for backend development.

Common Commands

  • node file.js → Run a JavaScript file
  • node → Open the interactive REPL (Read-Eval-Print Loop)
  • node --version (node -v) → Check Node.js version
  • node --inspect file.js → Runs a script with debugging enabled.

2. npm (Node Package Manager) Commands

Overview: npm is the default package manager for Node.js, used to install and manage dependencies.

Common Commands

  • npm init → Initialize a new project

  • npm install package-name → Install a package

  • npm install -g package-name → Install a package globally

  • npm run script-name → Run a script from package.json

  • npm update → Update all dependencies

  • npm uninstall package-name → Removes a package.

  • npm run script-name → Runs a script from package.json. Example: npm run start


3. yarn (Alternative to npm) Commands

Overview: Yarn is a faster and more efficient alternative to npm for package management.

Common Commands

  • yarn init → Initialize a project
  • yarn add package-name → Install a package
  • yarn global add package-name → Install a package globally
  • yarn run script-name → Run a script
  • yarn upgrade → Upgrade dependencies

4. npx CLI Commands

Overview: npx allows running Node.js packages without installing them globally.

Common Commands

  • npx create-react-app my-app → Create a new React app
  • npx eslint . → Run ESLint without global installation
  • npx tsc --init → Initializes TypeScript configuration

5. pnpm (Fast Package Manager) CLI Commands

Overview: pnpm is a modern package manager that saves space by linking dependencies instead of duplicating them.

Common Commands

  • pnpm init → Initialize a project
  • pnpm add package-name → Install a package
  • pnpm run script-name → Run a script

6. React.js CLI Commands

Overview: React is a JavaScript library for building user interfaces, especially single-page applications (SPAs).

Common Commands

  • npx create-react-app my-app → Create a new React app
  • npm start → Start the development server
  • npm run build → Build the app for production
  • npm run test → Runs tests.

7. Next.js CLI Commands

Overview: Next.js is a React-based framework that enables server-side rendering and static site generation.

Common Commands

  • npx create-next-app@latest my-app → Create a Next.js project
  • npm run dev → Start the development server
  • npm run build → Build for production
  • npm start → Start production server
  • npm run lint → Lint the project

8. Vue.js CLI Commands

Overview: Vue.js is a progressive JavaScript framework used to build interactive user interfaces.

Common Commands

  • npm install -g @vue/cli → Install Vue CLI
  • vue create my-app → Create a new Vue app
  • npm run serve → Start the development server
  • npm run build → Build for production
  • vue add package-name → Adds a Vue plugin

9. Angular CLI Commands

Overview: Angular is a TypeScript-based framework for building scalable web applications.

Common Commands

  • npm install -g @angular/cli → Install Angular CLI

  • ng new my-app → Create a new Angular app

  • ng serve → Start the development server

  • ng build → Build the project

  • ng test → Runs unit tests.

  • ng generate component my-component → Creates a new component.


10. Vite.js CLI Commands

Overview: Vite is a fast build tool and development server for modern JavaScript applications.

Common Commands

  • npm create vite@latest my-app --template react → Create a Vite app
  • npm run dev → Start the development server
  • npm run build → Build for production

11. Express.js CLI Commands

Overview: Express is a lightweight Node.js framework for building backend APIs and web applications.

Common Commands

  • npm install express → Install Express
  • node server.js → Run an Express app

12. NestJS CLI Commands

Overview: NestJS is a Node.js framework for building scalable server-side applications using TypeScript.

Common Commands

  • npm install -g @nestjs/cli → Install NestJS CLI
  • nest new my-app → Create a new NestJS project
  • npm run start → Start the development server

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs