1001Ferramentas
📦Dev

package.json Generator

Build a minimal package.json: name, version, description, scripts, license, repository, type (module/commonjs). Everything in your browser.

A minimal package.json without the prompts

npm init walks you through ten questions in the terminal, and npm init -y hands back fields you will delete anyway. Here you fill in name, version, description, author, license, type (module or commonjs) and main, and the JSON updates on every keystroke, indented and ready to save. An empty description or author is dropped from the output instead of sitting there as an empty string.

The field that trips people up is type. Choosing module changes what every .js file in the package means: they become ES modules, require and __dirname are gone, and relative imports need the extension (./util.js). A file that has to stay CommonJS must be renamed .cjs. The name field is not validated here either, and npm only accepts lowercase, no spaces, 214 characters max, so something like My Project is rejected at publish time.

The scripts are fixed: start runs node against whatever you typed into main, and test is the placeholder that exits with an error. Replace both once you paste. There is no field for dependencies, repository or exports, and dependencies do not need one anyway since npm install writes them for you. If the project is private, add private true by hand, because that is the flag that stops an accidental publish. All assembled in the browser.

Frequently asked questions

module or commonjs?
For a new project on a current Node, module. Stay on commonjs when the code is already full of require calls and you do not want to rewrite it today.
What is the difference between main and exports?
main is the legacy entry point; exports is the modern map and also blocks deep imports into your internal files. This page writes main only, which still works.
Does version matter if I never publish?
npm expects valid semver either way, and plenty of tooling reads the field. Keep the x.y.z shape even on an internal project.

Related Tools