Javascript - npm (Node package manager)

About

Npm is the package manager that is packaged/installed with a node installation.

Management

Installation

Update

To update npm self, execute the following statement:

npm install npm@latest -g
C:\Users\gerard\AppData\Roaming\npm\npm -> C:\Users\gerard\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
C:\Users\gerard\AppData\Roaming\npm
`-- [email protected]
  +-- [email protected]
  +-- [email protected]
  +-- [email protected]
........................

npx upgrade with npm

Version

npm -v
4.5.0

Script

See What are npm scripts and how to use them ? The script property of Package.json

Config

npm gets its config settings from:

  • the command line,
  • environment variables,

The npm config command can be used to update and edit the contents of the user and global npmrc files.

Environment variable

Npm reads configuration from any environment variables beginning with NPM_CONFIG.

Config file ( .npmrc)

The .npmrc file is in your project’s root.

npm config get userconfig   # defaults to ~/.npmrc 
C:\Users\gerard\.npmrc

npm config get globalconfig # defaults to /usr/local/etc/npmrc 
C:\Users\gerard\AppData\Roaming\npm\etc\npmrc

Registry

Heading Text Not found

npm config get registry
https://registry.npmjs.org/

Default Directory

npm config get prefix
C:\Users\foo\AppData\Roaming\npm

node-module

Prior to npm@3, the node_modules dependency structure had its own node_modules folder with all of its dependencies specified in package.json.

node_modules
└─ foo
   ├─ index.js
   ├─ package.json
   └─ node_modules
      └─ bar
         ├─ index.js
         └─ package.json

With npm@3 the node_modules structure is now flat:

node_modules
├─ foo
|  ├─ index.js
|  └─ package.json
└─ bar
   ├─ index.js
   └─ package.json

Source code may require dependencies that are not added as dependencies to the project.

Documentation / Reference





Discover More
CSS - Sass (scss)

Sass is a css preprocessor. It has four syntax parsers: scss (Sassy CSS), sass, CSS, and less with with
CommonJs (NodeJs) - Require

The import functionality implementation of commonjs (and then node) is done via the require function require basically: reads a Javascript file (generally a CommonJs module but it may be any javascript...
Card Puncher Data Processing
D3 - Node.js

D3 runs also on Node. use to install it. Note that because Node itself lacks a DOM and multiple DOM implementations exist for it (e.g., JSDOM), you'll need to explicitly pass in a DOM element to your...
Welcome From Browser
How to develop, publish and use a javascript library ?

A step by step tutorial on how to create and publish a javascript library
Javascript - Bouwer (Package manager)

Bouwer is a package manager. install git with the option bower/bower/wiki/Troubleshooting“Run Git from the Windows Command Prompt”. Bower is built on top of Git. install node.Js. It comes...
Javascript - Toolchain (Build tools)

This page is building/shipping in the context of Javascript A JavaScript build toolchain typically consists of: A package manager to install and update package such as yarn, npm. A bundler (such...
Javascript - Yarn

Yarn is a package manager It aims to resolve two problems: to download the library only once by having a local repository to fix the code of the dependency. Library authors may have change the code...
Javascript Package - Global Package (Cli)

There are two type of packages. This article goes over the global package (for the whole OS). They are managed with the npm cli. Yarn (in Windows home\AppData\Local\Yarn\bin\) from the registry...
Javascript Package - Package Manager

This article talks package manager in Javascript. They are the first component of the web toolchain as they permit to: declare package as dependency download and update package create a package...
Javascript Package - Package.json

Package.json is used by npm to store metadata for projects published as package. The package.json files: * serves as documentation for what packages your project depends on. * allows you to specify...



Share this page:
Follow us:
Task Runner