(Managed to get one working here: https://www.npmjs.com/package/api-gateway-direct-dynamodb)
Documenting the steps to publish a Typescript project to npm.
Check that tsconfig.json
is emitting declaration files:
"declaration": true,
"outDir": "./dist",
Compiles all Typescript source files and generates type declarations files:
rm -rf ./dist
npx tsc
Check that ./dist
contains the compiled .js and .d.ts files.
Edit package.json
to inform users' compilers on where to find the type declarations:
"main": "dist/index.js",
"types": "dist/index.d.ts",
This next step is optional, which is to test the library locally before publishing. Create another empty project and try to installing the library:
npm install path/to/my-package
Finally, publish the library:
npm publish
(For subsequent republishing, we would also need to increment the version number in package.json.
Top comments (0)