1

I am a beginner to Linux. I am using 14.04 Ubuntu. When I tried to install node I found a -g flag which says that if you install with it, it can be accessed globally.

So I tried to install nodejs and npm without typing -g flag in the command

I ran these commands

cd /projects/basics
sudo apt-get install npm
sudo apt-get install nodejs

When I moved to the root folder using the cd command and checked npm --version and node --version it shows the corresponding versions.

So what's the need of the -g flag?

Oli
  • 293,335
Learner
  • 113

1 Answers1

3

The commands:

sudo apt-get install npm
sudo apt-get install nodejs

are for installing npm, and nodejs globally in your Ubuntu, but the -g flag is for installing npm packages globally for your development. That has nothing to do with apt-get command. To install an npm package to only a specific development folder you leave out the -g flag and that means you can only use that package in that dev folder.

George Udosen
  • 36,677