Рет қаралды 28,292
All FREE courses - automationstep...
Every Node.js project has package.json file located in the root folder
Information about NodeJS project
List of dependencies with version
How to create :
npm init
npm init --y
package name
version
description
entry point
test command:
keywords:
author:
license
git repository:
dependencies
Package.json
records the minimum version needed (with ^ and ~)
is used for more than dependencies -like defining project info, description, author & license, scripts, etc
Package-lock.json
records the exact version of each installed package which allows you to re-install them
locks the dependencies with the installed version
When you run npm update packagename - it will update in package-lock.json and not in package.json
npm install - will install dependencies as per package.json
npm ci - will install dependencies as per package-lock.json
Do you need both package-lock.json and package.json? No
Do you need the package.json? Yes
Can you have a project with only the package-lock.json? No
Difference between tilde (~) and caret (^) in package.json
On npm install get the latest minor or patch version of the dependency mentioned in package.json
^ install the latest minor version - 1.x.x
tells npm that if someone clones the project and runs npm install then install the latest minor version of the package in his node_modules
~ install the latest patch version - 1.2.x
tells npm that if someone clones the project and runs npm install then install the latest patch version of the package in his node_modules
~1.2.3 will match all 1.2.x versions but will miss 1.3.0
^1.2.3 will match any 1.x.x release including 1.3.0, but will hold off on 2.0.0
#PackageJson
#NodeJS
____________________________________________________________
Stories by Raghav - automationstep...
My Udemy Courses - automationstep...
Every LIKE & SUBSCRIPTION gives me great motivation to keep working for you
You can support my mission for education by sharing this knowledge and helping as many people as you can
If my work has helped you, consider helping any animal near you, in any way you can
Never Stop Learning
Raghav