Questions tagged [npm]

npm is the package manager shipped with Node.js. It can be used to install and publish CommonJS and ECMAScript modules, jQuery plugins, reusable JavaScript code (libraries), JavaScript-based CLI programs, and more.

npm is the package manager shipped with .

npm can be used to install and publish and ECMAScript modules as well as JavaScript-based CLI programs. See the npm homepage for more information.

npm has the ability to install packages to a local directory or globally with the -g flag. Global packages are generally CLI programs.

npm packages manage dependencies and pass information to npm through the file. It contains entries for package name, version, git, dependencies, and other information. The official documentation can be found here.

npm uses the system. This system promote three version stages as well as suffixes. For example, v1.2.3-alpha. npm supports modifiers such as asterisks and greater/less than signs when specifying dependencies. More information can be found here and here.

As of April 14, 2015 npm also supports private modules that can be defined and used only by users who you specify. More about private modules here.

npm comes bundled with the installation of NodeJS, so there is no need for a separate install.

To search for modules:

Documentation Links:

Useful links:

49337 questions
705
votes
20 answers

Local dependency in package.json

I want to do something like this, so npm install also installs the package.json of ../somelocallib or more importantly its dependencies. "dependencies": { "express": "*", "../somelocallib": "*" }
user1680104
  • 8,437
  • 4
  • 22
  • 27
703
votes
34 answers

Unable to resolve dependency tree error when installing npm packages

When trying to install the npm packages using npm i command, I am getting the following exception: I have tried reinstalling the Node.js package and setting the proxy to off using: set HTTP_PROXY= set HTTPS_PROXY= The issue is still there. What I…
Pearl
  • 8,373
  • 8
  • 40
  • 59
701
votes
7 answers

How can I specify the required Node.js version in package.json?

I have a Node.js project that requires Node version 12 or higher. Is there a way to specify this in the packages.json file, so that the installer will automatically check and inform the users if they need to upgrade?
Erel Segal-Halevi
  • 33,955
  • 36
  • 114
  • 183
664
votes
9 answers

What is the difference between "npm install" and "npm ci"?

I'm working with continuous integration and discovered the npm ci command. I can't figure what the advantages are of using this command for my workflow. Is it faster? Does it make the test harder, okay, and after?
Webwoman
  • 10,196
  • 12
  • 43
  • 87
650
votes
6 answers

npm install vs. update - what's the difference?

What is the practical difference between npm install and npm update? When should I use which?
Borek Bernard
  • 50,745
  • 59
  • 165
  • 240
647
votes
11 answers

Installing a local module using npm?

I have a downloaded module repo, I want to install it locally, not globally in another directory? What is an easy way to do this?
fancy
  • 48,619
  • 62
  • 153
  • 231
626
votes
4 answers

What is the meaning of the "at" (@) prefix on npm packages?

In the Angular Component Router documentation I just stumbled over a npm command I have never seen before and I don't understand what is going on: npm install @angular/router --save What is the meaning of @angular/router? Is the whole string a…
jbandi
  • 17,499
  • 9
  • 69
  • 81
610
votes
13 answers

How to find unused packages in package.json?

Is there a way to determine if you have packages in your package.json file that are no longer needed? For instance, when trying out a package and later commenting or deleting code, but forgetting to uninstall it, I end up with a couple packages that…
Josh C
  • 7,461
  • 3
  • 24
  • 21
608
votes
11 answers

How do I override nested NPM dependency versions?

I would like to use the grunt-contrib-jasmine NPM package. It has various dependencies. Part of the dependency graph looks like this: ─┬ grunt-contrib-jasmine@0.4.1 │ ├─┬ grunt-lib-phantomjs@0.2.0 │ │ ├─┬ phantomjs@1.8.2-2 Unfortunately, there's…
georgebrock
  • 28,393
  • 13
  • 77
  • 72
600
votes
29 answers

How can I update npm on Windows?

I tried this: sudo npm cache clean -f sudo npm install -g n sudo n stable ...but it didn't work. How do I do this on Windows?
Jatin
  • 14,112
  • 16
  • 49
  • 78
587
votes
21 answers

How to set environment variables from within package.json?

How to set some environment variables from within package.json to be used with npm start like commands? Here's what I currently have in my package.json: { ... "scripts": { "help": "tagove help", "start": "tagove start" } ... } I…
dev.meghraj
  • 8,542
  • 5
  • 38
  • 76
574
votes
24 answers

How do I add comments to package.json for npm install?

I've got a simple package.json file and I want to add a comment. Is there a way to do this, or are there any hacks to make this work? { "name": "My Project", "version": "0.0.1", "private": true, "dependencies": { "express": "3.x", …
Will Shaver
  • 12,471
  • 5
  • 49
  • 64
552
votes
10 answers

How do you reinstall an app's dependencies using npm?

Is there a simple way to reinstall all packages that my app depends on (i.e. they are in my apps node_modules folder)?
trusktr
  • 44,284
  • 53
  • 191
  • 263
529
votes
8 answers

What is the role of the package-lock.json?

npm@5 has been published, it has a new feature package-lock.json file (after npm install) which confuses me. I want to know, what is the effect of this file?
SecretCastle
  • 5,299
  • 3
  • 9
  • 7
527
votes
19 answers

Node.js - SyntaxError: Unexpected token import

I don't understand what is wrong. Node v5.6.0 NPM v3.10.6 The code: function (exports, require, module, __filename, __dirname) { import express from 'express' }; The error: SyntaxError: Unexpected token import at exports.runInThisContext…
SofDroid
  • 5,450
  • 2
  • 13
  • 16