All Questions
577
questions
3015
votes
32
answers
2.2m
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>
...
1268
votes
18
answers
513k
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 --...
1044
votes
19
answers
773k
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 ...
782
votes
8
answers
578k
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 ...
679
votes
11
answers
571k
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?
526
votes
16
answers
1.0m
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 ...
389
votes
16
answers
275k
views
How to install a private NPM module without my own registry?
I've taken some shared code and put it in an NPM module, one I don't want to upload to the central registry. The question is, how do I install it from other projects?
The obvious way is probably to ...
233
votes
10
answers
123k
views
NodeJS require a global module/package
I'm trying to install globally and then use forever and forever-monitor like this:
npm install -g forever forever-monitor
I see the usual output and also the operations that copy the files to the ...
221
votes
15
answers
142k
views
How do I view the size of npm packages?
When I search for packages on NPM, I would like to see package sizes (in KB or MB, etc). NPM doesn’t seem to show this information.
How can I determine how much bloat an NPM package will add to my ...
205
votes
6
answers
136k
views
Npm install failed with "cannot run in wd"
I am trying to get my node environment set up on a new Ubuntu 12.04 instance, with Node 0.8.14 already installed, but I ran into problems when I try to run npm install.
So when I try npm install, it ...
201
votes
12
answers
132k
views
how to install multiple versions of package using npm
Due to https://github.com/npm/npm/issues/2943, npm will never support the ability to alias packages and install multiple versions of the same package.
The workarounds posted on the github issue might ...
190
votes
14
answers
147k
views
Node package ( Grunt ) installed but not available
I'm trying to build a github jquery-ui library using grunt, but after running npm install I still can't run the command according to the readme file. It just gives No command 'grunt' found:
james@...
179
votes
7
answers
121k
views
Should I commit yarn.lock and package-lock.json files?
We're using yarn for all our deterministic pkg installations but don't prevent the user from using npm - I'm guessing having both these files will cause issues however. Should one be added to your ....
178
votes
17
answers
111k
views
How to npm publish specific folder but as package root
I have a project that include a gulp task for building and packaging the sources and release in a directory called dist. My goal is publish it as a npm package, but only my dist folder. The npm ...
163
votes
9
answers
122k
views
Download source from npm without installing it
How can I download the source code of a package from npm without actually installing it (i.e. without using npm install thepackage)?
153
votes
8
answers
208k
views
Print a list of all installed node.js modules
In a node.js script that I'm working on, I want to print all node.js modules (installed using npm) to the command line. How can I do this?
console.log(__filename);
//now I want to print all ...
138
votes
5
answers
184k
views
How to install a node.js module without using npm?
There are quite a few modules which are listed on node's github page but are not published with the npm-registry. These modules can't be installed using npm.
What is the correct way to install these ...
126
votes
3
answers
63k
views
Do you put Babel and Webpack in devDependencies or Dependencies?
I'm new to npm and don't really understand what should go into dependencies vs. devDependencies. I know that for testing libraries they should go into dev, but how about for things like babel and ...
99
votes
4
answers
31k
views
Automatically Build NPM Module On Install From Github
Given that a project's lib/ dir shouldn't be checked into Git because the files it contains are derived files (from the build process). When installing a package from the project's github (during ...
90
votes
3
answers
90k
views
Installing "global" npm dependencies via package.json [duplicate]
I have a few "global" dependencies (jshint, csslint, buster, etc..) that I'd like to have automatically installed and executable via the command line when my package is installed via npm install. Is ...
86
votes
12
answers
188k
views
Unable to resolve dependency tree Reactjs
I am trying to install react-tinder-card in my current project. So I am trying to install the react-tinder-card but after I use the command
npm install --save react-tinder-card
All I can see in my ...
70
votes
22
answers
37k
views
Error while creating new React app ("You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0)")
I am getting this create React app error again and again even after doing the uninstall part.
npm uninstall -g create-react-app
up to date, audited 1 package in 570ms
found 0 vulnerabilities
npx ...
66
votes
3
answers
38k
views
Install a locally developed npm package globally
I'm developing a node package that needs to be run from shell. I know I have to install the package globally, but running
$> npm install -g ./my_module
Does not give me the desired result, that ...
63
votes
8
answers
67k
views
Global NPM package installed but command not found
I have globally installed two npm packages "download" and "enigmavirtualbox" via command line:
npm install -g download and
npm install -g engimavirtualbox
I'm trying to use them in a batch file to ...
51
votes
3
answers
23k
views
Is Lerna needed anymore with NPM workspaces?
Is Lerna needed anymore with NPM 7.0.0 workspaces?
I don't really have experience with this new npm feature.
npm/RFCs writes:
First and foremost there’s the alternative of leaving the problem set
for ...
49
votes
4
answers
45k
views
Update multiple dependencies with Bower
I listed (and/or installed) several dependencies with Bower inside the bower.json file and/or with
bower install https://github.com/username/project.git
That worked fine.
Now I can list all them ...
48
votes
3
answers
38k
views
NPM package 'bin' script for Windows
Cucumber.js is supplying a command-line "binary" which is a simple .js file containing a shebang instruction:
#!/usr/bin/env node
var Cucumber = require('../lib/cucumber');
// ...
The binary is ...
44
votes
4
answers
35k
views
Npm package.json inheritance
Is there a mechanism in npm like parent pom in Maven.
The goal is to have a common base configuration for scripts, dependencies, devDependencies.
Not based on templates like yeoman or so, but based on ...
43
votes
10
answers
113k
views
Package is not publishing to npm (not in the npm registry)
I would like to publish my git repository to npm so I can use it in other projects. But when I run the npm publish command I get the following error:
npm ERR! code E404
npm ERR! 404 Not Found - PUT ...
35
votes
7
answers
20k
views
Can I run a private npm repository without replicating the public repository?
I'm writing a number of pieces of code (for internal use) using node.js and want to store the modules (packaged up for npm) in a package repository for each distribution to the various machines they ...
31
votes
4
answers
23k
views
How to automatically copy files from package to local directory via postinstall npm script?
I want to automatically copy certain files from an npm package to user's local directory after running
npm install my-package
I can get them installed by declaring "files" inside package.json. The ...
27
votes
3
answers
21k
views
how do i confirm i'm using yarn link correctly?
How can I tell my local linked package is in use rather than from remote? Is it suppose to show up in the dev server of my local package?
25
votes
1
answer
7k
views
How do I see the release notes for an npm package before I upgrade?
Does the npm registry expose release notes in a standardized way? I've seen release notes in:
The README.md
On GitHub as a tagged release with no description
On GitHub as a tagged release with a ...
23
votes
5
answers
45k
views
Using npm how can I download a package as a zip with all of its dependencies included in the package
What I'm trying to do is download packages with all their dependencies, in order to transfer them to another computer that does not have an internet connection and install it there.
So the scenario ...
22
votes
3
answers
26k
views
Use npm package on client side
is there a way I can use an npm package on the client side? For example, I want to use the dateformat(https://www.npmjs.com/package/dateformat) package in my client side javascript file
21
votes
1
answer
12k
views
Failed doing npm install showing error "Undefined variable standalone_static_library in binding.gyp" and node-sass chokidar error
I'm updating a 3 years ago ruby on rails and react project trying to npm install but im stuck here getting this error
$ npm install
gyp: Undefined variable standalone_static_library in binding.gyp ...
19
votes
3
answers
11k
views
how can I force npm 3 to install nested dependencies?
I just upgraded to npm version 3 and noticed one of the biggest changes it made is that it enforces a flat dependency tree.
Your dependencies will now be installed maximally flat. Insofar as is ...
18
votes
1
answer
10k
views
Create npm package using webpack
I'm creating an npm package and using webpack for loader like babel, eslint etc.. However I'm under assumption that final compiled version of the package should only contain that one module, without ...
17
votes
4
answers
11k
views
How to count the number of installed packages, including dependencies
Is there an easy way to obtain a count of installed npm packages, both global and local to an application?
For example, after running create-react-app [1], I get screens-full of packages and ...
17
votes
1
answer
2k
views
What is the preferred way to publish a wasm library on npm?
Is there a good way to publish a library that uses a wasm binary on npm ?
So far, I encountered several issues. Ideally, I would like something that would be :
Totally transparent to the user. They ...
15
votes
3
answers
49k
views
How to run start scripts from package.json?
I've two scripts in package.json
"start:dev": "nodemon ./src/index.js",
"start": "npm run build && node ./build/index.js",
npm start works well.
I need to run "start:dev": "nodemon ./src/...
15
votes
3
answers
23k
views
Where does node.js put its files?
I have recently started playing with node.js, but I got lost in a big mess of different versions of node, npm, nvm and other packages. I don't know what is installed globally and what is installed ...
14
votes
7
answers
13k
views
How can I update all npm packages/modules at once?
I'm struggling to find a way to update all npm packages in one go, some articles suggest that package.json file should be edited where all version numbers need to be changed to * therefore forcing ...
14
votes
6
answers
15k
views
Error publishing a new version of a package in npm
I'm trying to republish a package using npm. I did update the package version in package.json, yet I get the following error:
npm ERR! publish Failed PUT 404
npm ERR! Windows_NT 6.3.9600
npm ERR! ...
14
votes
1
answer
4k
views
Does yarn ignore .npmignore?
I'm creating a npm package for self-learning purpose and published it on Github repo. The idea is that I want to install the package from one of the branch github repo rather.
My folder contains:
a/
...
13
votes
2
answers
7k
views
Change root directory on npm publish
Is it possible to change the root directory of my Node.js npm package when I do a publish? What I have is following:
├── lib
├── package.json
├── .npmignore
├── src
│ ├── index.js
│ └── sub
│ ...
12
votes
2
answers
7k
views
Node.js: Get (absolute) root path of installed npm package
Task
I'm looking for an universal way to get the (absolute) root path of an installed npm package in Node.js.
Problem
I know about require.resolve, but that will give me the entry point (path to ...
12
votes
0
answers
662
views
Should polyfills be a dependency or a devDependency?
As explained by this SO post, polyfills should be in the dependency folder.
However, the Array.find() polyfill has the following installation instructions.
npm install --save-dev jspolyfill-array....
11
votes
2
answers
11k
views
Module vs. Dependency vs. Library vs. Package vs. Component
I understand that packages hold several modules, but I'm starting to get confused as to if packages and modules are dependencies. Also, libraries to me maybe seem like packages you install via NPM, ...
10
votes
1
answer
14k
views
Use auth token to query a private NPM registry for a given package version, but without filesystem access?
The purpose of this effort is to be able to test whether a package version exists in a private registry, without having to touch the filesystem / config files. For packages in public registries this ...