What is package.json?

Why Interviewers Ask This

Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Node.js basics — a prerequisite for any developer role.

Answer

package.json is the manifest file for a Node.js project. It is a JSON file that records important metadata about your project and manages its dependencies. Key fields include: name and version (required for published packages), description, main (entry point file), scripts (custom commands like "start": "node index.js"), dependencies (packages required in production), devDependencies (packages only needed during development like testing tools), peerDependencies (packages the consumer must install), engines (required Node.js version), and license. The scripts field is particularly useful for defining build, test, and start commands. Generate it with npm init (interactive) or npm init -y (defaults).

Common Mistake

A common mistake is memorizing definitions without understanding implications. When asked this question, go one level deeper — explain what happens when this concept is misused or ignored.