Loading

Quipoin Menu

Learn • Practice • Grow

node-js / Introduction to npm
interview

Q1. What is npm?
npm (Node Package Manager) is the default package manager for Node.js. It consists of a command-line client and an online registry of packages. It helps developers install, share, and manage dependencies in Node.js projects. npm comes bundled with Node.js, so installing Node.js automatically installs npm.

Q2. What are the main functions of npm?
npm allows you to: install packages (npm install), manage dependencies in package.json, share your own packages, run scripts defined in package.json, update packages, and manage different versions. It also helps in publishing packages to the npm registry for others to use.

Q3. What is the difference between npm and npx?
npm is used to install and manage packages. npx is a tool to execute Node packages without installing them globally. npx runs a package once, useful for trying out packages or running tools without polluting global installations. For example, npx create-react-app my-app runs the package without permanent install.

Q4. What is the npm registry?
The npm registry is a large public database of JavaScript packages. It's the default registry where npm fetches packages from. It contains millions of packages that developers can use in their projects. You can also set up private registries for company-specific packages.

Q5. How do you check the version of npm?
Run npm --version or npm -v in your terminal. This displays the installed npm version. To update npm itself, you can run npm install -g npm@latest. npm is updated more frequently than Node.js, so it's good to keep it up to date.