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:

38836 questions
537
votes
13 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
  • 6,597
  • 4
  • 19
  • 26
511
votes
17 answers

Cannot install packages using node package manager in Ubuntu

NodeJS interpreter name(node) on Ubuntu has been renamed to nodejs because of a name conflict with another package. Here's what the readme. Debian says: The upstream name for the Node.js interpreter command is "node". In Debian the interpreter…
Sayem
  • 5,939
  • 4
  • 20
  • 22
494
votes
7 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
  • 41,315
  • 56
  • 147
  • 225
494
votes
16 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,109
  • 2
  • 11
  • 15
471
votes
37 answers

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

What might be causing the error Error: EACCES: permission denied, access '/usr/local/lib/node_modules'? npm ERR! path /usr/local/lib/node_modules npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall access npm ERR! Error: EACCES: permission…
hendra dedi
  • 4,735
  • 3
  • 7
  • 7
445
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
  • 34,715
  • 41
  • 148
  • 226
432
votes
3 answers

npm command to uninstall or prune unused packages in Node.js

Is there a way to simply uninstall all unused (undeclared) dependencies from a Node.js project (ones that are no longer defined in my package.json.) When I update my application I like to have the unreferenced packages removed automatically.
Tarion
  • 14,013
  • 11
  • 61
  • 98
431
votes
20 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
  • 10,683
  • 5
  • 44
  • 62
427
votes
25 answers

Command to remove all npm modules globally?

Is there a command to remove all global npm modules? If not, what do you suggest?
EhevuTov
  • 19,227
  • 16
  • 63
  • 71
427
votes
5 answers

Depend on a branch or tag using a git URL in a package.json?

Say I've forked a node module with a bugfix and I want to use my fixed version, on a feature branch of course, until the bugfix is merged and released. How would I reference my fixed version in the dependencies of my package.json?
hurrymaplelad
  • 23,777
  • 9
  • 50
  • 72
425
votes
12 answers

Is there a way to automatically build the package.json file for Node.js projects

Is package.json supposed to be manually edited? Couldn't a program like npm just look through the files, see the "require" statements, and then use that to put the necessary entries in the package.json file? Are there any programs like that?
neuromancer
  • 47,047
  • 74
  • 161
  • 217
424
votes
3 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
  • 14,967
  • 8
  • 62
  • 75
409
votes
17 answers

Why does npm install say I have unmet dependencies?

I have a node package. When I run npm install from the package root, it installs a bunch of things, but then prints several error messages that look like this: npm WARN unmet dependency…
Sean Mackesey
  • 9,554
  • 8
  • 34
  • 58
400
votes
16 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
  • 6,346
  • 4
  • 34
  • 69
399
votes
14 answers

How to clean node_modules folder of packages that are not in package.json?

Assume I install project packages with npm install that looks into package.json for modules to be installed. After a while I see that I don't need some specific module and remove its dependency from package.json. Then I remove some other modules…
Sergei Basharov
  • 43,294
  • 56
  • 177
  • 295