
Consuming jsr packages
4/25/2025
JSR is a package registry for modern JavaScript, that means it provides packages exporting ESM modules or even TypeScript code for Deno and other runtimes supporting TypeScript natively.
JSR builds your package with TypeScript type definition files (.d.ts) and can generate documentation based on JSDoc comments.
How to consume a JSR package in Node.js ?
I am using npm as my package manager so I will show you how to install a JSR package with npm compatibility.
For this little demo, I will use a tiny jsr package
Using the jsr cli
To add a JSR package, you need to use the jsr cli, with npm you can do so by executing this command:
$ npx jsr add @leex/add
This will add this entry in your package.json:
{
"dependencies": {
"@leex/add": "npm:@jsr/leex__add@^0.0.0"
}
}
This is using the special scope @jsr to choose the correct registry.
You can check your .npmrc and see the added scope:
@jsr:registry=https://npm.jsr.io
Note that your .npmrc should be committed for your CI to work and enable your coworkers to install jsr deps.
Package content inspection
Let’s see what’s inside our newly added package.
node_modules/@leex/add/
├── add.js
├── add.js.map
├── add.ts
├── _dist
│ ├── add.d.ts
│ └── add.d.ts.map
├── jsr.json
└── package.json
Note that the author only published add.ts and the 2 .json files. Other files have been generated by jsr.
So jsr generated:
- A JS version of the TS source file
- A sourcemap (add.js.map), to link positions in the generated js to the ts file.
- A _dist folder containing typescript definition files, useful in your preferred editor.
Here is an example of what I see in VSCode:

Let’s execute our little code:
$ node ./index.js
84
Looks like it works !
The jsr documentation provides everything you need to install/publish your packages with your preferred package manager and use the exported modules in your JS runtime.