A minimal TypeScript starter for creating npm packages with support for CommonJS, ESM, and TypeScript definitions.
- ⚡ TypeScript
- 📦 Build with tsup
- 📜 Outputs CJS, ESM, DTS
- ✨ ESLint + Prettier preconfigured
git clone https://github.com/egiev/node-package-starter.git <package_name>
cd <package_name>
npm install{
"name": "@your-scope/your-package",
"version": "0.1.0",
"description": "Your package description",
"author": "Your Name",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/your-username/your-package.git"
},
"bugs": {
"url": "https://github.com/your-username/your-package/issues"
},
"homepage": "https://github.com/your-username/your-package#readme"
}Replace this README content with information about your package.
Write your code in src/.
Example src/index.ts:
export function hello(name: string): string {
return `Hello, ${name}! 👋`;
}npm run buildThis generates:
- dist/index.js → CommonJS build
- dist/index.mjs → ESM build
- dist/index.d.ts → TypeScript types
- dist/index.d.mts → ESM TypeScript types
npm pack
# produces your-package-1.0.0.tgz
npm install ../path-to/your-package-1.0.0.tgznpm run lint
npm run lint:fix
npm run formatnpm login
npm version patch # or minor / major
npm publish --access publicimport { hello } from '@your-scope/your-package';
console.log(hello('World'));const { hello } = require('@your-scope/your-package');
console.log(hello('World'));This project is licensed under the MIT