On this page
deno link
deno link 命令会将你的项目指向 JSR 包的本地副本,这样你就可以使用它来替代已发布版本进行开发。它相当于手动编辑 deno.json 中的
links 数组的命令行版本,并且其工作流程类似于 npm link 或 bun link。
链接包 Jump to heading
传入本地包目录的路径:
deno link ../my-local-pkg
目标必须是一个包含 deno.json 或带有 name 字段的 package.json 的目录,这样 Deno 才知道它对应的是哪个包。Deno 会将相对路径追加到最近的 deno.json 中的 links 数组里(如果该数组不存在则会创建),然后安装依赖。被链接的包可以通过其裸名称导入,就像工作区成员一样,因此不会添加 imports 条目。
再次链接相同路径不会产生额外影响。你可以在一条命令中链接多个包:
deno link ../pkg-a ../pkg-b
移除链接 Jump to heading
使用 deno unlink 来停止使用本地
副本:
deno unlink ../my-local-pkg
deno link [OPTIONS] [paths]...Link a local JSR package into the current project for development.
deno link ../my-local-pkg
Each path must be a directory containing a deno.json with a JSR-style "name" field. The path is appended to the "links" array in the nearest deno.json, and modules imported by that package's name resolve to the local copy instead of the registry.
To stop using the local copy:
deno unlink ../my-local-pkg
deno unlink @scope/name
Dependency management options Jump to heading
--frozen<BOOLEAN>optionalError out if lockfile is out of date.
--lock<FILE>optionalCheck the specified lock file. (If value is not provided, defaults to "./deno.lock").
--no-lockDisable auto discovery of the lock file.
Options Jump to heading
--lockfile-onlyInstall only updating the lockfile.