Node.js
/Beginner
package.json
Definition
The heart of any Node.js project. It is a JSON file that holds metadata about the project, manages dependencies (libraries), and defines runnable scripts.
Explain Like I'm New
It's the recipe and instruction manual for your application. If you give your code to a friend, they don't have your downloaded libraries. They look at the `package.json` recipe, run `npm install`, and NPM automatically downloads all the exact ingredients needed to run your app.
Real World Example
Running `npm run dev`. Node looks in the `package.json` under the `"scripts"` object, finds the `"dev"` key, and executes the complex terminal command tied to it (like `nodemon src/index.js`).
Common Use Cases
- •Dependency management
- •Automating terminal tasks via scripts
- •Publishing packages to NPM
Interactive Example
Loading...
Console output will appear here...
Interview Questions
basic
- What command generates a new `package.json` file?
intermediate
- What is the difference between `dependencies` and `devDependencies`?
advanced
- What do the `^` (caret) and `~` (tilde) symbols mean in front of version numbers?