Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does it mean to npm install -g

Tags:

node.js

npm

Just a newbie question, I am trying to install the Less from Node.js platform. the command line is npm install -g less. I check the doc from here

In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.

What does it mean global package ? thanks.

like image 958
Joe.wang Avatar asked Jul 07 '14 08:07

Joe.wang


People also ask

What does npm install mean?

The npm install installs all modules that are listed on package. json file and their dependencies. npm update updates all packages in the node_modules directory and their dependencies.

What happens when npm install?

npm install (in package directory, no arguments): Install the dependencies in the local node_modules folder. In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.

Why do we need to npm install?

It helps with installing various packages and resolving their various dependencies. It greatly helps with your Node development. NPM helps you install the various modules you need for your web development and not just given you a whole bunch of features you might never need.

What is npm install in node JS?

What is NPM? NPM is a package manager for Node. js packages, or modules if you like. www.npmjs.com hosts thousands of free packages to download and use. The NPM program is installed on your computer when you install Node.js.


1 Answers

You are not required to install Less as global, the Less ReadMe instruction is: npm install less.


Installing it local, means the module will be available only for a project you installed it (the directory you were in, when ran npm install).

Global install, instead puts the module into your Node.js path (OS dependent), and will be accessible from any project, without the need to install it separately for each.

See Diagram of Module look-up to understand how exactly modules are loaded when required by Node.js project.


In the end, I suggest you install it as global, as less is highly popular module, and you will very likely need it more than once.

like image 68
alandarev Avatar answered Sep 18 '22 23:09

alandarev