Reload Deno cache after upgrading

Aug 08, 2020 • 2 minutes to read

Since it's v1.0 release, the Deno framework is iterating in a very fast pace. It releases a new version almost every other week. It is generally a good idea to keep your Deno install updated with the latest release. The deno command provides a built-in upgrading tool. The following command upgrades Deno to the latest release.

$ deno upgrade

You can also upgrade or downgrade to a specific version of Deno, like this:

deno upgrade --version 1.2.0

However, the way Deno works is that it caches dependency TypeScript files when it builds or runs an application. Examples include the Deno std library files. When you upgrade or downgrade Deno, the cached files are supposed to refresh to reflect the current version of Deno. But, that does not always happen. That's when you see error messages like these.

error: TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname
                 ~~~
    at https://deno.land/std/path/win32.ts:917:18

TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname;
                 ~~~
    at https://deno.land/std/path/posix.ts:438:18

Found 2 errors.

The solution is actually quite simple. Just force Deno to reload the cached files for your application.

$ deno cache --reload my_app.ts

And then you can build and run your Deno application normally. Happy coding!

Denofaq
A high-performance, extensible, and hardware optimized WebAssembly Virtual Machine for automotive, cloud, AI, and blockchain applications