With npm, installing the necessary library is very easy. You need to open a terminal in your project folder and run the following command:
npm install library_name
For example, let's install the lodash library:
npm install lodash
The installed library will be locateŠ²
in the node_modules
folder. In
this case, if the library has dependencies,
they will also be installed in this
folder as separate libraries.
Libraries installed via npm can be included in an HTML file. But you shouldn't do this, since they are modules. Such libraries should be included in a special way. We will go through this in the next sections of the tutorial. In the meantime, we just learn how to install libraries via npm.
Install the
underscorejs
library via npm. Examine the
node_modules
folder.
Install the
jQuery
library via npm. Examine the
node_modules
folder.