package.json Basics
Create package.json
In an empty project folder:
npm init -y
Key fields
nameandversionidentify the packagemainorexportspoint to the entry file for librariesscriptsdefine shortcuts likestartandtestdependencieslists packages your app needs to run
Mark the module type
For ES modules in .js files:
{
"name": "my-app",
"version": "1.0.0",
"type": "module",
"scripts": {
"start": "node app.js"
}
}
Commit the lockfile
After installing packages, commit package-lock.json so installs stay reproducible.
Comments
One comment per signed-in account. Comments are saved with this page’s URL.