Search code examples
deno

How to update `deno.lock` on removing a dependency?


When I add a dependency in my code, the deno.lock file gets updated and I see that the package's URL is visible in deno.lock.

Now when I remove the import from my code and run deno cache --reload <file.ts>, the previous URL is still visible.

Ideally I'd want the state to be such that I never installed that package.


Solution

  • In the newest Deno versions, this should happen by default whenever deno executes/caches your dependencies again. (unless lock.frozen is true in your deno.json)

    For version >= 1.45,

    deno --frozen=false cache -A main.ts
    

    For versions < 1.45,

    deno --lock-write=true cache -A main.ts