@types package is needed.
Package managers
Requirements
- Node.js 18 or newer (the SDK uses native
fetch,FormData,Blob, andAbortController) - ESM module resolution (see TypeScript setup below)
- A valid BosonMail API key
TypeScript setup
Because the package is ESM-only, your project must resolve it as an ES module. Intsconfig.json, use one of these combinations:
tsconfig.json
tsconfig.json
"type": "module" in your package.json:
package.json
CommonJS workaround
If your project uses CommonJS (require), dynamically import the default export:
commonjs.cjs
Verify the installation
Create a small script that constructs the client and prints the base URL. If this runs without errors, the package is installed correctly.verify.ts
Troubleshooting
ERR_REQUIRE_ESM
ERR_REQUIRE_ESM
You are trying to
require() an ESM-only package. Switch to import, add "type": "module" to package.json, or use the dynamic import workaround shown above.fetch is not defined
fetch is not defined
Upgrade to Node.js 18 or newer. The SDK relies on the global
fetch implementation and does not bundle a polyfill.Cannot find module
Cannot find module
Ensure your
tsconfig.json uses "moduleResolution": "NodeNext" or "bundler", and that the package is listed in package.json dependencies. Delete node_modules and lockfiles and reinstall if needed.Next steps
Quickstart
Send your first email in under five minutes.
Authentication
Set up your API key and Bearer token security.