When using package.json one of the most important things is to install dependencies..
For no dependencies you can write one line: "dependencies": {}
If you want a dependencie for example react you can do it single-lined but its recommended to make it multi-line:
{
"dependencies": {
"react": "^18.2.0"
}
}
The first number 18 indicates major update when that ticks up.
The second number after the first period indicates a minor update when that ticks up.
The third number after the second period indicates a patch when that ticks up.
Using ^ at the start means it will auto-update versions that update the second or third number. but it wont auto-update it if it changes the first number(EG: 18 > 19 will not happen ).
Using ~ at the start means it will auto-update versions that update the third number. but it wont auto-update it if it changes the first or second number(EG: 18.1.0 > 18.2.0 will not happen ).
Using no prefix and just putting the version number means it will auto-update any version even if it changes the first or second or third number.
Inequality ranges let you specify the exact versions that can be auto-updated you can set the minimum version and the maximum version (Use if you want more control over version auto-updating).
In your JSON, you will need to add:
{
"dependencies": {
"dependencieName": "[PREFIX]DependencyVersion",
// comments only available with .JSONC files; remove from package.json.
// add your other dependencies here
}
}
Hope that helped! If you have any questions you may ask them in the comments.
Top comments (0)