JSR - JavaScript Registry
JSR is the recommended package registry for Deno. It’s designed specifically for TypeScript and provides better type information and documentation.Installing JSR Packages
Add JSR packages to yourdeno.json:
deno.json
Direct JSR Imports
You can also import directly without configuration:Using the deno add Command
The easiest way to add packages is usingdeno add:
deno.json with the package.
npm Packages
Deno has native support for npm packages with no additional setup required.Installing npm Packages
Add npm packages to yourdeno.json:
deno.json
Using deno add for npm
Direct npm Imports
Lock Files
Deno uses adeno.lock file to ensure consistent dependency resolution across environments.
Enabling Lock Files
Lock files are enabled by default. Configure indeno.json:
deno.json
deno.json
Frozen Lock File
In CI/CD environments, use frozen mode to ensure the lock file is up to date:deno.json
Updating the Lock File
The lock file updates automatically when you add or update dependencies:Node Modules Directory
Deno can optionally create anode_modules directory for better npm compatibility.
Configuration
deno.json
"auto"- Create node_modules automatically when npm packages are used"manual"- Only use node_modules if it exists"none"- Never use node_modules (default)
When to Use node_modules
Use node_modules when
- Working with tools that expect node_modules
- Need better IDE integration for npm packages
- Debugging npm package issues
Avoid node_modules when
- Using primarily JSR packages
- Want faster installation
- Prefer Deno’s global cache
Dependency Caching
Deno caches dependencies globally by default.Cache Location
Cache Directory
By default, Deno caches to:- Linux/Mac:
~/.cache/deno - Windows:
%LOCALAPPDATA%\deno
DENO_DIR environment variable:
Vendoring Dependencies
Vendor dependencies to commit them to your repository:deno.json:
deno.json
vendor directory with all dependencies.
Version Management
Semantic Versioning
deno.json
Updating Dependencies
Workspaces
Manage multiple packages in a monorepo:deno.json
deno.json:
Publishing to JSR
Minimum Dependency Age
Protect against supply chain attacks by requiring a minimum age for dependencies:deno.json
deno.json
- Minutes:
"120"(120 minutes) - ISO-8601 duration:
"P2D"(2 days) - RFC3339 date:
"2025-09-16" - RFC3339 timestamp:
"2025-09-16T12:00:00+00:00"
npm Lifecycle Scripts
Control whether npm packages can run lifecycle scripts:deno.json
deno.json
Best Practices
Prefer JSR over npm
Prefer JSR over npm
Use JSR packages when available for better TypeScript support and documentation.
Pin versions in production
Pin versions in production
Use exact versions in production environments:
Use lock files
Use lock files
Always commit your
deno.lock file to ensure consistent dependencies.Cache dependencies in CI
Cache dependencies in CI
Example: Full Package Configuration
deno.json