05 / 10

How to install delete and update a dependency in node js?

  1. 1

    npm install <package-name>

  2. 2

    npm install <package-name> --save-dev

  3. 3

    npm update <package-name>

  4. 4

    npm uninstall <package-name>

Difficulty: 4/10
Topics: npm install/remove/update, package.json versioning, lockfile management

Scenario Questions

0-2 years experience
  1. 1

    You need to add the 'express' package to a new Node.js project. Walk me through the exact command you would run and what files get changed.

  2. 2

    After realizing that 'lodash' is no longer used, how would you remove it and ensure the project still runs correctly?

  3. 3

    If you want to upgrade 'mongoose' to the latest minor version without changing the major version, what npm command would you use and why?

2-5 years experience
  1. 1

    Your CI pipeline started failing after you ran 'npm update' on a shared library. How would you investigate the cause and decide whether to roll back or adjust the version range?

  2. 2

    You have three microservices that each depend on 'axios' but at slightly different versions. How would you consolidate the dependency across the services while minimizing breakage?

  3. 3

    Explain the trade‑offs between installing a testing tool as a devDependency versus a regular dependency in a production codebase.

5-8 years experience
  1. 1

    Design a process for managing third‑party dependencies in a large monorepo, covering installation, version pinning, automated updates, and security scanning.

  2. 2

    A transitive dependency of 'react-scripts' has a critical CVE, but the top‑level package hasn't released a fix yet. What steps would you take to mitigate the risk?

  3. 3

    Compare npm's package-lock.json with npm shrinkwrap in the context of CI/CD pipelines for a high‑traffic service. Which would you choose and why?

8+ years experience
  1. 1

    Your organization wants to migrate from npm to pnpm across dozens of services. Outline the architectural considerations, migration steps, and how you'd ensure minimal disruption.

  2. 2

    How would you establish organization‑wide policies for dependency updates, including automated pull requests, version range strategies, and audit compliance?

  3. 3

    Describe how you would design an internal package registry to reduce external dependency risk and improve build reproducibility for all teams.

Follow-up Questions

  • What does the ^ symbol mean in a version range?
  • How do lockfiles affect reproducible builds?
  • When would you prefer a devDependency over a regular dependency?