JS: Setting up the environment
Theory: Global package installation
Some Node.js packages are not just plug-in libraries, but rather complete programs. For example, there is a JavaScript utility called sloc which can count the number of lines of code in a project. This utility itself is not tied to JavaScript, it works with source files in many different languages.
Such utilities are not associated with a specific project or even JavaScript. The implication is that they can be used by anyone. For these cases, there is another way to install it in npm – global. Take a look at an example:
The -g flag indicates that the package should be installed globally. You can run this command from anywhere on the file system. npm adds this package to a special directory accessible to all system users. You can find out its location with another npm command:
After installation, the utility becomes available on the command line by a name specified in the project documentation, e.g., on GitHub. In the case of sloc, the name of the package is the same as the command name:

