To override this behavior, use the command below (where tag is the package’s tag like beta, latest, etc.). Npm install will use the latest tag by default. The command to install the ExpressJS package globally would then be: npm install -g express If you notice, the command is very similar to the basic command to install a package, however, the only difference is the versionnumber that follows the package name as a suffix. The following command installs global packages into the /User/local/lib/node_modules folder. npm install email protected Example showing npm command to install specific version of package. This creates a node_modules directory in the project’s current directory (if one doesn’t exist yet) and downloads the package to that directory.įor example, to install the ExpressJS package, simply write the command: npm install express The following command installs any third-party module in the project’s folder. Example: Let’s suppose, you had installed Axios npm package version 0.18.0 but now you want to downgrade it to 0.15.0 then you can do something like below: 1. The following codes demonstrates various variations on the npm install command. If there is a package.json file, npm will install the latest version that satisfies the semver rule declared in package.json. If there is no package.json file in the local directory, then the latest version of the package is installed. The name is simply the name of the package to be installed. Here, the scope specifies whether the package is to be installed locally or globally. The following command is used to install packages using npm.
0 Comments
Leave a Reply. |