A package that is published can be downloaded and installed by any user. You simply need to go to the folder and give the command, npm install sample package. This installs the package locally. On the other hand, if you wish to install the package globally, you can give the command, npm install –g sample package.
For a global installation, you will need to create a link from each application to the global install using the command, npm link sample package. The route to a global install is a junction. You can get into the node_modules folder and back using the cd command.
Once you are inside the folder, you can give the command: npm install Contoso, to initiate an install. You can now write some code that uses the package.
This code tests the modules of the package. You can execute the code using:
The package can be uninstalled locally using:
npm uninstall sample package
However, if you wish to uninstall the package globally, you can do it using
npm uninstall -g sample package
How to Use Express
- The first step is to install Node.js and create a sample for keeping all .js files and projects. Besides this, you must also install Express, which is a web application framework for Node.js development.
- You can create a package using the following set of commands and instructions
- You can use the command, npm ls, to see if the package is present in the registry.