Package foundations
Write package.json deliberately
Set identity, version, module type, entry points, scripts, engines, and repository metadata with intent.
9 minute lesson
Start from the behavior you can observe. The package declares a scoped name, initial version, ESM type, supported Node range, license, repository, and test script.
package.json is both local project configuration and published package metadata, so each field affects tools or consumers. The useful target is not encyclopedic coverage. Make one deliberate choice, observe its consequences, and know which requirement would make you revise it.
It is tempting to accept generated metadata without checking what consumers and the registry will see. That trades a clear decision for an assumption you will eventually have to debug. The stronger move is to keep only accurate fields, validate the package name and version, and document the supported runtime. Make the boundary explicit in code and in the project notes.
Tie the decision back to the larger job: Turn a useful function into a small package whose public surface and published files are intentional. Record enough evidence that another developer can repeat the result without relying on your memory.
Create the manifest by hand, run npm metadata commands, and explain every retained field in one sentence. Repeat it once with an invalid or hostile condition and write down the boundary the failure revealed.
Lesson completed