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.
49,548
questions
5181
votes
21
answers
1.6m
views
What's the difference between tilde(~) and caret(^) in package.json?
After I upgraded to the latest stable node and npm, I tried npm install moment --save. It saves the entry in the package.json with the caret ^ prefix. Previously, it was a tilde ~ prefix.
Why are ...
3005
votes
14
answers
1.1m
views
What is the --save option for npm install?
I saw some tutorial where the command was:
npm install --save
What does the --save option mean?
2941
votes
35
answers
2.1m
views
Find the version of an installed npm package
How can I find the version of an installed Node.js or npm package?
This prints the version of npm itself:
npm -v <package-name>
This prints a cryptic error:
npm version <package-name>
...
2835
votes
17
answers
926k
views
What's the difference between dependencies, devDependencies, and peerDependencies in NPM package.json file?
This documentation answers my question very poorly. I didn't understand those explanations. Can someone say in simpler words? Maybe with examples if it's hard to choose simple words?
Also added ...
2696
votes
42
answers
1.5m
views
How can I update each dependency in package.json to the latest version?
I copied package.json from another project and now want to bump all of the dependencies to their latest versions since this is a fresh project and I don't mind fixing something if it breaks.
What's ...
2397
votes
14
answers
989k
views
Do I commit the package-lock.json file created by npm 5?
npm 5 was released today and one of the new features include deterministic installs with the creation of a package-lock.json file.
Is this file supposed to be kept in source control?
I'm assuming it'...
2107
votes
65
answers
2.1m
views
How can I update Node.js and NPM to their latest versions?
I just installed Node.js and NPM (Node Package Manager). I installed NPM for access to additional Node.js modules.
After I installed Node.js and NPM, I noticed that neither were the latest versions ...
2063
votes
7
answers
308k
views
NPM vs. Bower vs. Browserify vs. Gulp vs. Grunt vs. Webpack [closed]
I'm trying to summarize my knowledge about the most popular JavaScript package managers, bundlers, and task runners. Please correct me if I'm wrong:
npm & bower are package managers. They just ...
1900
votes
8
answers
330k
views
What is the difference between Bower and npm?
What is the fundamental difference between bower and npm? Just want something plain and simple. I've seen some of my colleagues use bower and npm interchangeably in their projects.
1722
votes
35
answers
2.7m
views
How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
My version of node is always v0.6.1-pre even after I install brew node and NVM install v0.6.19.
My node version is:
node -v
v0.6.1-pre
NVM says this (after I install a version of node for the first ...
1488
votes
39
answers
665k
views
How to fix npm throwing error without sudo
I just installed node and npm through the package on nodejs.org, and whenever I try to search or install something with npm, it throws the following error unless I sudo the command. I have a feeling ...
1459
votes
23
answers
1.2m
views
Where does npm install packages?
Can someone tell me where can I find the Node.js modules, which I installed using npm?
1400
votes
23
answers
1.6m
views
How can I uninstall npm modules in Node.js?
As commonly known, any npm module can be installed by running a simple command: npm install <module_name>.
I have installed a few modules that I do not use any more and I just want to get them ...
1383
votes
23
answers
952k
views
Sending command line arguments to npm script
The scripts portion of my package.json currently looks like this:
"scripts": {
"start": "node ./script.js server"
}
...which means I can run npm start to start the server. So far so good.
...
1211
votes
18
answers
466k
views
What is the difference between --save and --save-dev?
What is the difference between:
npm install [package_name]
and:
npm install [package_name] --save
and:
npm install [package_name] --save-dev
What does this mean? And what is really the effect of --...
1203
votes
22
answers
810k
views
How to install an npm package from GitHub directly
Trying to install modules from GitHub results in this error:
ENOENT error on package.json.
Easily reproduced using express:
npm install https://github.com/visionmedia/express throws error.
npm ...
1185
votes
10
answers
1.0m
views
How to install a previous exact version of a NPM package?
I used nvm to download node v0.4.10 and installed npm to work with that version of node.
I am trying to install express using
npm install express -g
and I get an error that express requires node ...
991
votes
19
answers
689k
views
How to list npm user-installed packages
How do I list the user-installed / environment package only in npm?
When I do npm -g list, it outputs every package and their dependencies. Instead I'd like to see the packages installed in the ...
977
votes
30
answers
600k
views
xcode-select active developer directory error
Saw the following error when running an npm install which required node-gyp... but could be triggered by anything which requires xcode-select.
xcode-select: error: tool 'xcodebuild' requires Xcode, ...
971
votes
26
answers
359k
views
Difference between npx and npm?
I have just started learning React, and Facebook helps in simplifying the initial setup by providing the following ready-made project.
If I have to install the skeleton project I have to type npx ...
933
votes
13
answers
425k
views
Why does "npm install" rewrite package-lock.json?
I just recently upgraded to npm@5. I now have a package-lock.json file with everything from package.json. I would expect that, when I run npm install that the dependency versions would be pulled ...
916
votes
12
answers
664k
views
Error "npm WARN package.json: No repository field"
I installed Express.js with the following command:
sudo npm install -g express
I get the following warnings:
npm WARN package.json rang[email protected] No repository field.
npm WARN package.json fresh@...
889
votes
31
answers
520k
views
Is there a way to get version from package.json in nodejs code?
Is there a way to get the version set in package.json in a nodejs app? I would want something like this
var port = process.env.PORT || 3000
app.listen port
console.log "Express server listening on ...
850
votes
15
answers
550k
views
How do you prevent install of "devDependencies" NPM modules for Node.js (package.json)?
I have this in my package.json file (shortened version):
{
"name": "a-module",
"version": "0.0.1",
"dependencies": {
"coffee-script": ">= 1.1.3"
},
"devDependencies": {
"...
832
votes
20
answers
912k
views
npm check and update package if needed
We need to integrate Karma test runner into TeamCity and for that I'd like to give sys-engineers small script (powershell or whatever) that would:
pick up desired version number from some config file ...
810
votes
30
answers
267k
views
nvm keeps "forgetting" node in new terminal session
Upon using a new terminal session in OS X, nvm forgets the node version and defaults to nothing:
$ nvm ls:
.nvm
v0.11.12
v0.11.13
I have to keep hitting nvm use v.0.11.13 in ...
747
votes
32
answers
838k
views
How to specify a port to run a create-react-app based project?
My project is based on create-react-app. npm start or yarn start by default will run the application on port 3000 and there is no option of specifying a port in the package.json.
How can I specify a ...
721
votes
25
answers
445k
views
How to use executables from a package installed locally in node_modules?
How do I use a local version of a module in node.js. For example, in my app, I installed coffee-script:
npm install coffee-script
This installs it in ./node_modules and the coffee command is in ./...
713
votes
63
answers
507k
views
Node Sass couldn't find a binding for your current environment
I am having issues building an app because node-sass keeps failing with the error.
ERROR in Missing binding /Users/warren/Sites/random-docs/my-cms/node_modules/node-sass/vendor/darwin-x64-11/...
709
votes
42
answers
840k
views
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! ...
708
votes
34
answers
1.4m
views
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=
...
707
votes
20
answers
685k
views
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": "*...
707
votes
7
answers
486k
views
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 ...
668
votes
9
answers
346k
views
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,...
650
votes
6
answers
290k
views
npm install vs. update - what's the difference?
What is the practical difference between npm install and npm update? When should I use which?
648
votes
11
answers
504k
views
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?
632
votes
4
answers
105k
views
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 ...
616
votes
11
answers
424k
views
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-ja[email protected]
│ ├─┬ [email protected]
│...
614
votes
13
answers
342k
views
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 ...
600
votes
29
answers
1.7m
views
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?
589
votes
21
answers
935k
views
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 ...
577
votes
24
answers
219k
views
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"...
553
votes
10
answers
637k
views
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)?
531
votes
8
answers
329k
views
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?
528
votes
19
answers
837k
views
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: ...
525
votes
19
answers
258k
views
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 ...
511
votes
4
answers
322k
views
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 ...
510
votes
10
answers
533k
views
What does 'x packages are looking for funding' mean when running `npm install`?
I usually get "x packages are looking for funding." when running npm install on a react project. Any idea what that means?
509
votes
22
answers
757k
views
How can I change the version of npm using nvm?
I've been using NVM to install the latest versions of Node.js for my Node.js work. It works totally fine for installing separate versions and switching between them. It also installs the latest ...
503
votes
17
answers
934k
views
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 ...