This repository template makes it easier to create a new NPM library, package or application using Node.js and TypeScript. It comes with several developer tools pre-configured and ready to use, so it's easier to get started.
You can create a new repository based on this template by clicking the "Use this template" button in the top-right corner of this page.
You can run the following command below with the GitHub CLI. Some notes:
--public
, --private
, or --internal
gh repo create {{package}} --public --clone --template neoncitylights/typescript
Using your favorite text editor or IDE, find-and-replace the following placeholders:
@author/package
: Replace this with the name of your package. This can be scoped under a user/organization (e.g @samantha/my-really-cool-package
). Note: This placeholder is different than the others to avoid warnings from the NPM client.{{author}}
: Replace this with your GitHub/npm username, or the name of your organization.{{package}}
: Replace this with the name of your library.{{desc}}
: Replace this with a short description of your library.Delete this README.md
, and rename LIBRARY.md
to README.md
.
if you haven't authenticated with the NPM CLI already, you'll need to do that first by running npm adduser
in the terminal.
To publish a non-scoped package (e.g my-cool-package
), run npm publish
To publish a scoped package (e.g @namespace/my-cool-package
), pass the --access
flag, which must be either public
or private
. For example:
npm publish --access public
[!NOTE] To publish a private package on NPM, you must have npm Pro.
For your CI environment (when using GitHub Actions), you'll need to set the NPM_TOKEN
environment variable to the value of your NPM token. You can find this by running npm token list
in the terminal, and create a token by running npm token create
.
To add your token to your repository:
NPM_TOKEN
as the name of the secretNPM has core commands that can be overriden by package authors. I've tried to make this as zero-config as possible, so its likely you won't need to change them any further. These commands are:
These are the most relevant commands that you'll likely use:
Command | Description |
---|---|
npm run build |
Build the library for distributing |
npm run docs |
Generate documentation |
npm run docs:watch |
Generate documentation in watch mode |
npm run clean |
Remove all generated files |
npm run reinstall |
Cleans and reinstalls dependencies |
npm run lint |
Check for linting errors |
npm run lint:fix |
Fix linting errors |
npm run test |
Run unit tests |
npm run test:ci |
Run unit tests in CI mode |
npm run test:ui |
Run unit tests in UI/browser mode |
npm run test:watch |
Run unit tests in watch mode |
Tool | File | Documentation |
---|---|---|
NPM package | package.json |
docs, website |
TypeScript | tsconfig.json |
docs, website |
TypeDoc (documentation generator) | tsconfig.json (typedocOptions ) |
docs, website |
ESLint (code formatter + linter) | .eslintrc.cjs |
docs, website |
Markdownlint (Markdown linter) | .markdownlint-cli2.jsonc |
docs |
Vite (bundler) | vite.config.ts |
docs, website |
Vitest (testing framework) | vite.config.ts (test ) |
docs, website |
Vitest workspace | vitest.workspace.ts |
docs |
CodeSandbox CI | .codesandbox/ci.json |
docs, website |
Dependabot | .github/dependabot.yml |
docs, website |
This software is licensed under the MIT license (LICENSE-MIT
or https://opensource.org/license/mit/).
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.