The document discusses Node Package Manager (NPM), which is used to install, update, and manage dependencies for Node.js packages and applications. NPM allows developers to publish and install open source packages, and also manages packages locally or globally on a system. It covers how to install packages locally or globally, add dependencies to a project's package.json file, update existing packages, and uninstall packages.
Introduction to NPM and its functionalities. NPM is a tool for installing, updating, and managing Node.js packages, included with Node.js installation.
NPM operates in two modes: Global and Local. Global affects all applications; Local only affects the specific project directory.
Commands for installing packages like ExpressJS in a local Node.js project, with all modules stored in the node_modules directory.
NPM allows global package installation affecting all Node.js applications. Use -g flag for global installation.
Commands to add dependencies directly in package.json during installation, along with an example of a package.json structure.
Instructions to update installed packages in a local project via the npm update command.
Command for removing a local package from a project, specifically the uninstallation of ExpressJS.
ďĄ npm standsfor Node Package Manager.
ďĄ npm is a command line tool that installs,
updates or uninstalls Node.js packages in your
application.
ďĄ It is an online repository for the publishing of
open-source Node.js packages.
ďĄ It is a command-line utility for interacting with
said repository that aids in package installation,
version management, and dependency
management. https://www.npmjs.com
4.
ďĄ NPM isincluded with Node.js installation. After
Node.js installation verify NPM installation by
following command
> npm âv
ďĄ If you have an older version of NPM then you can
update it to the latest version using the
following command.
> npm install npm âg or
> npm install âg npm@latest
ďĄ To access NPM help
>npm help
5.
ďĄ NPM performsthe operation in two modes:
ď§ Global
ď§ Local.
ďĄ In the global mode, NPM performs
operations which affect all the Node.js
applications on the computer.
ďĄ In the local mode, NPM performs operations
for the particular local directory which affects
an application in that directory only.
6.
ďĄ Use thefollowing command to install any third
party module in your local Node.js project folder.
ď§ >npm install <package name>
ďĄ For example, the following command will install
ExpressJS into NODEJS folder.
ď§ >NODEJS> npm install express
ďĄ All the modules installed using NPM are installed
under node_modules folder.
ďĄ The above command will create ExpressJS folder
under node_modules folder in the root folder of
your project and install Express.js there.
7.
ďĄ NPM canalso install packages globally so
that all the node.js application on that
computer can import and use the installed
packages.
ďĄ NPM installs global packages at path
/<User>/local/lib/node_modules folder.
ďĄ Apply -g in the install command to install
package globally. For example, the following
command will install ExpressJS globally.
ď§ >NODEJS> npm install -g express
8.
ďĄ Use --saveor npm init at the end of the install
command to add dependency entry into
package.json of application.
ďĄ For example, the following command will install
ExpressJS in application and also adds dependency
entry into the package.json.
ďĄ C:/Users/Administartor/NODEJS> npm install
express âsave
ďĄ The package.json of NODEJS project will look
something like below.
ďĄ To updatethe package installed locally in your
Node.js project, navigate the command prompt
or terminal window path to the project folder
and write the following update command.
C:> npm update <package name>
ďĄ The following command will update the existing
ExpressJS module to the latest version.
C:UsersAdministartorNODEJS > npm update
express
11.
ďĄ Use thefollowing command to remove a
local package from your project.
ďĄ C:>npm uninstall <package name>
ďĄ The following command will uninstall
ExpressJS from the application.
ďĄ C:UsersAdministratorNODEJS> npm
uninstall