jsr-io / jsr-npm

A cli tool to make installing packages form jsr.io in node easy
https://npmjs.com/package/jsr
MIT License
102 stars 13 forks source link

JSR npm command line tool

The JSR npm CLI integrates JSR (JavaScript Registry) packages with npm-based projects, facilitating the use of JSR packages in environments that traditionally rely on npm. Learn more about JSR at jsr.io.

Quick Start

Add a JSR package to your project:

npx jsr add @package/name  # 'install' and 'i' are also supported

This command auto-updates your package.json and installs the package, automatically detecting and using your project's package manager.

How It Works

The CLI creates or updates a .npmrc file in your project with:

@jsr:registry=https://npm.jsr.io

This line redirects npm to fetch JSR packages from the JSR registry instead of the default npm registry.

Packages are added to package.json with an alias, mapping the JSR package name to the npm registry URL hosted by JSR, like so:

{
  "dependencies": {
    "@luca/flag": "npm:@jsr/luca__flag@1"
  }
}

This ensures that the package is fetched from JSR when you run npm install commands.

Commands

Limitations

For the best developer experience and to fully leverage JSR's capabilities, consider environments with native JSR support like Deno.

Contributing

We welcome contributions and feedback. Visit our GitHub repository to contribute or report issues.

License

This CLI is available under the MIT License.