Registry / payments / taxjar

taxjar

JSON →
library2.0.1jsnpmunverified

The `taxjar` package provides the official Node.js client for integrating with the TaxJar Sales Tax API v2. It allows developers to perform sales tax calculations, manage order and refund transactions, list tax categories, retrieve tax rates for specific locations, manage customer records, and validate VAT numbers and addresses. The library is actively maintained; the latest stable major version is v5.0.0, which requires Node.js v18 or newer and leverages native `fetch`. Prior to this, v4.1.0 was the stable release. TaxJar typically follows a regular release cadence, addressing API changes and adding new functionalities. Its primary advantage is providing a direct, officially supported interface to the comprehensive TaxJar API, abstracting away HTTP request handling and API-specific nuances, making it easier for applications to comply with sales tax regulations.

npm install taxjar
INSTALL
IMPORT
SIG · TAXJAR
T
taxjar
paymentsjavascriptv2.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Taxjar
import Taxjar from 'taxjar';
import { Taxjar } from 'taxjar';
Taxjar is a default export for ESM. Ensure `esModuleInterop` is `true` in tsconfig.json for TypeScript projects.
Taxjar (CommonJS)
const Taxjar = require('taxjar');
const { Taxjar } = require('taxjar');
This is the correct CommonJS `require` syntax for the default export.
Taxjar (Type)
import type TaxjarClient from 'taxjar';
For type-only imports in TypeScript, use `import type`.

This quickstart demonstrates how to instantiate the TaxJar client using an API key and then asynchronously fetch the list of all available tax categories.

import Taxjar from 'taxjar'; const client = new Taxjar({ apiKey: process.env.TAXJAR_API_KEY ?? 'YOUR_TAXJAR_API_KEY', apiUrl: 'https://api.taxjar.com' // Optional: use 'https://api.taxjar.com/v2' or 'https://api.sandbox.taxjar.com' for sandbox }); async function getTaxCategories() { try { const res = await client.categories(); console.log('Available Tax Categories:', res.categories); } catch (error) { console.error('Error fetching tax categories:', error.message); } } getTaxCategories();
Debug
Known issues
breakingThe minimum Node.js version was increased from v10 to v18. Running on older Node.js versions with TaxJar v5+ will result in runtime errors.
fix
Upgrade your Node.js environment to version 18 or newer. Alternatively, use TaxJar v4.x.x if you must support older Node.js versions.
affects: >=5.0.0
breakingThe `node-fetch` dependency was removed in v5.0.0, and the client now relies on the native `fetch` API, which is available in Node.js v18 and later. This causes `ReferenceError: fetch is not defined` on older Node versions.
fix
Upgrade Node.js to v18 or later. If you are stuck on an older Node version, consider using TaxJar v4.x.x, which explicitly uses `node-fetch`.
affects: >=5.0.0
gotchaExposing your TaxJar API key in client-side JavaScript is insecure and could compromise your account. API keys should always be treated as sensitive credentials.
fix
Always store API keys securely, typically as environment variables on the server-side, and never embed them directly into client-side code bundles. Proxy API requests through your own backend if client-side access is required.
affects: *
gotchaWhen using TypeScript, if you encounter issues like `TypeError: Taxjar is not a constructor` with ESM imports, it's often due to TypeScript's module resolution settings.
fix
Ensure `"esModuleInterop": true` is set in your `tsconfig.json` under `compilerOptions` to correctly handle default imports from CommonJS modules.
affects: *
Errors
Common errors & fixes
TypeError: require is not a function
Attempting to use CommonJS `require` syntax in an ES module environment (e.g., a file with '.mjs' extension or `"type": "module"` in `package.json`).
fix
Use `import Taxjar from 'taxjar';` for ES modules. If you must use CommonJS, ensure your environment is configured for it (e.g., `"type": "commonjs"` or `.cjs` file extension).
TypeError: Taxjar is not a constructor
Incorrectly importing the Taxjar client, often by trying to destructure a default export (e.g., `import { Taxjar } from 'taxjar';`) or misconfiguring TypeScript's `esModuleInterop`.
fix
For ES modules, use `import Taxjar from 'taxjar';`. For CommonJS, use `const Taxjar = require('taxjar');`. If using TypeScript, ensure `"esModuleInterop": true` is set in `tsconfig.json`.
ReferenceError: fetch is not defined
Running TaxJar v5.0.0 or later on a Node.js version older than v18, which lacks native `fetch` API support.
fix
Upgrade your Node.js environment to v18 or newer. If upgrading is not an option, you would need to revert to TaxJar v4.x.x.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
node-fetchrequiredUsed for making HTTP requests to the TaxJar API in versions prior to v5.0.0.
Agent activity
36 hits · last 30 days
node
32
OpenAI (training)
1
Resources
taxjar — npm install taxjar · libregistry