Category: react
what is package.json in react
Published on 26 Mar 2026
Explanation
package.json is the main configuration file
of a React app π¦. It stores project
information like name, version, and whether
the
project is private. It acts as the
central control file for managing the app
setup.
Code:
{
"name": "my-react-app",
"version": "1.0.0",
"private": true
}
Explanation
The dependencies section lists all
libraries required
for the React app to run βοΈ.
When you run npm install, these packages
are automatically downloaded.
Code:
{ "dependencies": { "react": "^18.2.0",
"react-dom": "^18.2.0" }
}
Explanation
The scripts section defines reusable
commands like
starting or building the app π. You
can run them using npm start or
npm run build.
Code:
{ "scripts": {
"start": "react-scripts start",
"build": "react-scripts build"
}
}
Explanation
The version field represents the current
version
of the project π’. It helps track
updates and releases during development.
Code:
{ "version": "1.0.0" }
Explanation
The name field specifies the project name
π·οΈ. It is useful when publishing the
project as a package or identifying it
in development.
Code:
{ "name": "my-react-app" }
Explanation
The private field prevents accidental
publishing of
the project to npm π. It is
usually set to true for React applications.
Code:
{ "private": true }
Explanation
The devDependencies section stores packages
needed only
during development π οΈ, such as testing tools
or linters.
Code:
{ "devDependencies": { "eslint": "^8.0.0" } }
Explanation
The browserslist section defines which
browsers your
React app should support π. This helps
optimize compatibility and performance.
Code:
{ "browserslist": {
"production": [">0.2%", "not dead"],
"development": ["last 1 chrome version"]
}
}