deno remove command removes dependencies from your project’s configuration file.
Usage
Description
Removes packages from yourdeno.json imports or package.json dependencies. The command:
- Removes the dependency from your configuration file
- Updates the lockfile
- Removes unused packages from cache
deno.json and package.json (if present) for the specified packages.
Arguments
One or more package names or aliases to remove. Can be:
- Package name:
@std/assert - Import alias:
my-assert - With prefix:
jsr:@std/assertornpm:express
Options
Only update the lockfile, don’t remove packages from cache.
Examples
Remove a package by name
deno.json:
Remove multiple packages
Remove by alias
If you added with an alias:Remove with prefix
Only update lockfile
Behavior with Multiple Config Files
If bothdeno.json and package.json exist, the command:
- Searches for the package in both files
- Removes it from any file where it’s found
- Reports which package was removed
Example with both configs
deno.json:
package.json:
@std/assert from deno.json and express from package.json.
Removing from devDependencies
The command automatically searches bothdependencies and devDependencies in package.json:
typescript from devDependencies if present.
What Gets Removed
From deno.json
- Entries in the
importsmap - Empty
importsobject is preserved
From package.json
- Entries in
dependencies - Entries in
devDependencies - Empty objects are preserved
After Removal
After removing packages, the command automatically:- Updates the lockfile to remove unused entries
- Cleans up cached packages (unless
--lockfile-only) - Reports which packages were removed
Error Cases
Package not found
If a package isn’t found in any configuration file:No configuration file
If neitherdeno.json nor package.json exists:
Examples with Workspace
In a workspace, the command operates on the current directory’s configuration:Comparison with npm
Similar to npm/yarn remove:| npm/yarn | Deno |
|---|---|
npm remove express | deno remove express |
npm remove -D typescript | deno remove typescript (automatically finds in devDependencies) |
yarn remove @types/node | deno remove @types/node |
Notes
- The command is idempotent - running it multiple times has the same effect
- Removing a package doesn’t affect other packages that may depend on it
- The lockfile is automatically updated after removal
- Unused cached packages are cleaned up (improves disk usage)