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
23
votes
4 answers

How do I create a MySQL connection pool while working with NodeJS and Express?

I am able to create a MySQL connection like this: var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'localhost', user : 'me', password : 'secret', database :…
Utkarsh Kaushik
  • 901
  • 1
  • 6
  • 14
23
votes
3 answers

NodeJS: Merge two PDF files into one using the buffer obtained by reading them

I am using fill-pdf npm module for filling template pdf's and it creates new file which is read from the disk and returned as buffer to callback. I have two files for which i do the same operation. I want to combine the two buffers there by to form…
Abdul Vajid
  • 1,291
  • 1
  • 15
  • 25
23
votes
2 answers

Invalid HMR message error Webpack

I'm getting the following error from Webpack: Invalid HMR message Followed by a string of very detailed JSON. There really aren't any resources that I can find to better debug this. Any tips? Bonus if anyone can give me insight to why require can't…
John Doe
  • 3,559
  • 15
  • 62
  • 111
23
votes
1 answer

npm shrinkwrap extraneous module

There is the following problem - I installed all modules and I'm trying to make npm-shrinkwrap.json file: npm shrinkwrap But I always get the following error: npm ERR! Darwin 14.3.0 npm ERR! argv "/usr/local/Cellar/node/4.1.2/bin/node"…
malcoauri
  • 11,904
  • 28
  • 82
  • 137
23
votes
6 answers

Zsh: command not found: webpack

I'm learning React and installed webpack through npm to my project directory but zsh is not finding the command even though I can see webpack installed in my project. I used npm init --yes followed by npm install --save webpack
akantoword
  • 2,824
  • 8
  • 26
  • 43
23
votes
5 answers

-bash: gulp: command not found in Mac

I try install gulp in mac like this : Is-iMac:~ itop$ npm root /Users/itop/node_modules Is-iMac:~ itop$ npm config set prefix /usr/local Is-iMac:~ itop$ npm root -g /usr/local/lib/node_modules Is-iMac:~ itop$ sudo npm install -g gulp After Install…
ಠ_ಠ
  • 1,235
  • 2
  • 17
  • 29
23
votes
2 answers

How to include materialize-css npm package with webpack

I'm writing a client-side app that is using Webpack, and I cannot figure out how to require the materialize-css package. I'm using Henrik Joreteg's hjs-webpack package, and with this the yeticss npm package is included by doing an import in a sass…
neurodynamic
  • 4,294
  • 3
  • 28
  • 39
23
votes
3 answers

How can I update all Node.js modules automatically?

During my work with the Node.js environment, I faced the issue of version maintenance of Node.js modules. I would like to be sure that all internal Node.js modules are updated. Many of existing manuals focus just on how to update Node.js modules,…
Mike
  • 14,010
  • 29
  • 101
  • 161
23
votes
1 answer

Revert version of unpublished Node.js package

I have a package which I released on NPM and it's currently at version 1.0.1. I have made some changes locally, and wanted to publish them. I entered npm version 1.0.3 and then felt stupid, because I wanted to type npm version 1.0.2. How can I…
Stephan Bijzitter
  • 4,425
  • 5
  • 24
  • 44
23
votes
3 answers

npm glob pattern not matching subdirectories

In my package.json, I have a scripts block that uses **/*Test.js to match files. When run via npm, they do not match sub-directories more than one level. When executed on the command line directly, they work as expected. Can anyone explain what is…
David Souther
  • 8,125
  • 2
  • 36
  • 53
23
votes
3 answers

Webpack doesn't find a module that actually exists

I'm in trouble, I just did npm uninstall react-bootstrap and then npm install react-bootstrap and webpack cannot load this module anymore. I launch webpack like this : /var/www/cloud/node_modules/.bin/webpack --config webpack.config.js --watch…
Alex
  • 487
  • 1
  • 6
  • 16
23
votes
2 answers

How do I run an npm script of a dependent package

I have a package that itself has a script in its package.json that I would like to be able to run in my top-level project. This package is one of my top-level projects dependencies. I'm looking for a way to directly or indirectly call the dependency…
Nate
  • 12,963
  • 4
  • 59
  • 80
23
votes
2 answers

How can I whitelist a single file in a directory in .npmignore?

I'm trying to make npm download only a single file in a directory on npm install of the package. The directory looks like: +- dist/ +- 1.0.0/ +- 1.0.1/ +- ...lots of other dirs... +- file.js I want npm to ignore everything but file.js…
m90
  • 11,434
  • 13
  • 62
  • 112
23
votes
5 answers

gulp: Automatically add version number to request for preventing browser cache

I deploy my project by building source files with gulp right on the server. To prevent caching issues, the best practice could be adding a unique number to request url, see: Preventing browser caching on web application upgrades; In npm…
Dan
  • 55,715
  • 40
  • 116
  • 154
23
votes
4 answers

How to detect and measure event loop blocking in node.js?

I'd like to monitor how long each run of the event loop in node.js takes. However I'm uncertain about the best way to measure this. The best way I could come up with looks like this: var interval = 500; var interval = setInterval(function() { …
Fabian Jakobs
  • 28,815
  • 8
  • 42
  • 39