- Part 1: Definition of the MEAN stack
- Part 2: Setup of the MEAN stack
- Part 3: Node.js
- Part 4: npm
- Part 5: Connect
- Part 6: Express
- Part 7: MongoDB
- Part 8: Mongoose
- Part 9: REST
- Section 10: Baucis
- Part 11: Bower
- Part 12: AngularJS
- Part 13: Restangular
npm is a package manager for managing modules. That is, it makes installation and uninstallation of modules easier and also takes into account whether a particular module depends on another or not. It is installed by default with Node. In this article, I explain the use of npm.
Contrary to widespread opinion npm would be an abbreviation for Node Package Manager is npm not an abbreviation and also has no 100% meaningful meaning . When selecting the name as a command for the command line, care was taken that all letters can be entered easily with the right hand and without uppercase letters.
The current version of npm can be checked in the terminal:
$ npm – v
Although nod modules are distributed almost exclusively via npm, any other files can also be managed using npm.
As already shown, the creation and requisition of Node modules is very simple. npm improves this property of Node once again: Modules can be easily (de) installed and interdependencies between modules can be held. The (de) installation of modules can be done globally or locally. As a rule, modules are installed locally per project because projects can work with different versions of a module. The rule of thumb is merely to install Node modules, which are used as a command line tool, to be installed globally. All locally installed modules are stored in a subfolder of the current folder named
The installation of a module is done by a simple command (
modulnamemust be replaced by a real name of a module):
$ npm install module name
With the addition
install , the module would be installed globally.
uninstall the corresponding module can be uninstalled:
$ npm uninstall module name
The same command can be
-g applied again with the addition for global modules.
npm provides a way to
package.json hold the dependencies of a project declaratively in a JSON file named other modules . We do not need this function for the following simple examples. If you would like to know more about this common practice at this point, you can read it in the npm document at https://npmjs.org/doc/files/package.json.html . It is especially relevant for the release of its own Node modules at npm, or when working with other developers, so that each developer receives all the dependencies of a module. It can also contain metadata such as a link to the repository or information about the license.
Since we now know how to install external modules with npm, we can look at our first node framework in the next article.