91-9990449935 0120-4256464 |
Node.js Package ManagerNode Package Manager provides two main functionalities:
The npm comes bundled with Node.js installables in versions after that v0.6.3. You can check the version by opening Node.js command prompt and typing the following command: Installing Modules using npmFollowing is the syntax to install any Node.js module: Let's install a famous Node.js web framework called express: Open the Node.js command prompt and execute the following command: You can see the result after installing the "express" framework. Global vs Local InstallationBy default, npm installs dependency in local mode. Here local mode specifies the folder where Node application is present. For example if you installed express module, it created node_modules directory in the current directory where it installed express module. You can use npm ls command to list down all the locally installed modules. Open the Node.js command prompt and execute "npm ls": Globally installed packages/dependencies are stored in system directory. Let's install express module using global installation. Although it will also produce the same result but modules will be installed globally. Open Node.js command prompt and execute the following code: Here first line tells about the module version and its location where it is getting installed. Uninstalling a ModuleTo uninstall a Node.js module, use the following command: The Node.js module is uninstalled. You can verify by using the following command: You can see that the module is empty now. Searching a Module"npm search express" command is used to search express or module.
Next TopicNode.js Command Line Options
|