Template that you can use to create an executable script, ready to be published in NPM. It does not use any bundler.
If you are wondering whether or not you need a bundler for your purposes, you can read this answer on stackoverflow and maybe this blog article.
The procedure is straightforward:
- Use this project as a template.
- Replace all occurrences of 'script-executable-publishable' in
package.jsonwith your project name. Update the description, author, and license fields as needed. - Authentication & Registry:
- If you intend to publish to the public npm registry (npmjs.com), simply run:
You do not need a
pnpm login
.npmrcfile or a GitHub token for public npm. - If you intend to publish to GitHub Packages (npm.pkg.github.com), you need a
.npmrcfile with an auth token. You can use the provided.npmrc.example:cp .npmrc.example .npmrc # Then edit .npmrc and add your GitHub Personal Access Token (with write:packages scope)
- If you intend to publish to the public npm registry (npmjs.com), simply run:
- Install dependencies:
If you don’t have pnpm, follow this guide.
pnpm install
- Lint and format your code (recommended):
pnpm lint pnpm format
This project uses Biome for linting and formatting.
- (Recommended) Test your script locally before publishing. You can use
pnpm link --globalor these npm tips. - When you're ready to publish to npm, run:
pnpm publish --access public
- For public packages on npmjs.com, use:
pnpm publish --access public
- For private packages on npmjs.com, use a scoped package name (e.g.,
@yourname/package) and publish with:pnpm publish --access restricted
- For private packages on GitHub Packages, packages are private by default. Just publish as usual after configuring
.npmrc.
