- Oct 01, 2018
- admin
- 0
NodeJS Package Manager:
NPM or Node.js Package Manager manages the Node.js packages, which contains the files a user needs for a module. The NPM program is installed with Node.js installable automatically.
Downloading and Installing Modules using npm:
- Open the command line interface.
- Type Command npm install <Module Name>.
Example:
npm install upper-case
To include a Package:
Like any other module, a package is used the same way, i.e, Node.js require() function with the name of the module is used.
Syntax:
var variable_name = require(‘module_name’);
Local Installation of Packages:
By default, NPM creates a directory named “node_modules” in the current directory. All the installed packages are placed in this folder. This whole process is termed as local installation of packages.
Global Installation of Packages:
NPM places all the Globally installed packages in the system directory. For global installation of packages
- Open Node.js command prompt.
- Type Command npm install -g <Module Name>.
Example:
npm install -g upper-case
Here first line tells about the module version and its location where it is getting installed.
Uninstalling Modules using npm:
Open the command line interface.
- Type Command npm uninstall <Module Name>.
Example:
npm uninstall upper-case
NodeJS Interview Questions