npm

From XennisWiki
Jump to: navigation, search

npm is a package manager for JavaScript, and is default for Node.js. As of Node.js version 0.6.3, npm is bundled and installed automatically with the environment. npm runs through the command line and manages dependencies for an application. It also allows users to install Node.js applications that are available on the npm registry. (Wikipedia)

Install

Arch Linux

Install the npm package.

Debian

Install npm using APT

apt-get install npm

Packages

Install and uninstall a package (optionally with -g globally)

npm install [-g] PACKAGE-NAME
npm uninstall [-g] PACKAGE-NAME

Some packages:

package.json

Put a package.json in the root directory to use npm install to install all dependencies. Example file:

{
  "name": "YOUR-APP",
  "version": "0.1.0",
  "dependencies": {
    "leaflet-minimap": "~2.2.x"	
  },
  "devDependencies": {
    "gulp": "*",
    "gulp-util": "^3.0.6"
  }
}

Node.js

Node.js is an open source, cross-platform runtime environment for server-side and networking applications. Node.js applications are written in JavaScript, and can be run within the Node.js runtime on OS X, Microsoft Windows, Linux and FreeBSD. Node.js provides an event-driven architecture and a non-blocking I/O API that optimizes an application's throughput and scalability. These technologies are commonly used for real-time web applications. (Wikipedia)

Install

Arch Linux

Install the npm package.

Debian

You may also install nodejs-legacy.

apt-get install nodejs

To install the latest version

curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
apt-get install -y nodejs

See also

  • Bower JavaScript npm package manager
  • Composer PHP package manager

External links