Package.json Structure in NPM
From the NPM Package Manager cheat sheet · Project Setup & Initialization · verified Jul 2026
Package.json Structure
Essential fields in package.json
json
// package.json
{
"name": "my-project",
"version": "1.0.0",
"description": "Project description",
"main": "index.js",
"type": "module", // ES modules
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js",
"test": "jest",
"build": "webpack",
"lint": "eslint ."
},
"keywords": ["nodejs", "api"],
"author": "Your Name",
"license": "MIT",
"dependencies": {
"express": "^4.18.0"
},
"devDependencies": {
"nodemon": "^2.0.0",
"jest": "^29.0.0"
}
}🟢 Essential - package.json is the project manifest
💡 Use "type": "module" for ES modules
📌 Scripts are shortcuts for common commands
⚡ "files" field controls what gets published
⚠️ Name must be lowercase and URL-safe
package.jsonconfig