Npm install package with version syntax download#
You can download & install npm directly from using our custom install.sh script: curl -qL | sh Officially supported downloads/distributions can be found at: /en/download Direct Download Npm comes bundled with node, & most third-party distributions, by default. One of the following versions of Node.js must be installed to run npm: If you open package.Npm - a JavaScript package manager Requirements That way, when another developer on your team clones the repo and runs the npm install command, npm knows exactly which packages to install, keeping you and your colleague in sync. Both files are meant to be committed to your Git repo, and serve as your project’s dependency blueprint. It can replicate that environment precisely on anyone else’s machine, thanks to their info. When you share or collaborate with others on a project, npm knows where the project came from and exactly what you have installed in the project by these two files. So be sure to avoid mistaking the lockfile with the package.json file. The lockfile is also never supposed to be updated by hand only by npm.
The main packages you install may be listed in package.json, but package-lock.json is where the entire dependency tree is tracked. The difference is a little technical, but loosely explained: the lockfile is the in-depth, precise snapshot of the project’s dependency tree, and package.json is a high level overview, which can also contain other things. These two JSON files work together to ensure an accurate record of all the dependencies in your project (and all of their dependencies, and all of their dependencies’ dependencies, and so on).
Npm install package with version syntax plus#
Oddly, however, we do see a three new items in the project folder: two JSON files named package.json and package-lock.json, plus one entirely new node_modules folder. Once we’ve run the install command, you may notice that you do not see anything named “sass” in the project folder as you might expect. (This is why you see that npm added 16 packages and audited a total of 17 npm packages, instead of the Sass package alone-it, too, has dependencies!) If it finds that package (which it does), npm installs it to the project in an automatically generated node_modules folder (more on this in a bit) located in the project root folder, including everything the package needs to run. What’s happening behind the scenes there is that npm tries to find a package named sass in the npm package registry. That’s all you need! Type that and npm goes straight to work: For example, the Node package for Sass is simply called “sass” which means we can add to a project like this (just be sure you’re in a new folder you created for this little project first): npm install sass We can install our very first package with the npm install command (or npm i for short), followed by the name of the packages we want to add to our project.
By now, you’re becoming quite knowledgeable with npm! So far, we’ve broken down the three letters in “npm” to gain a better understand of Node and package managers.