Standard library

Deno provides a set of standard modules that are audited by the core team and are guaranteed to work with Deno.

Standard library is available at: https://deno.land/std/

Versioning and stability

Standard library is not yet stable and therefore it is versioned differently than Deno. For latest release consult https://deno.land/std/ or https://deno.land/std/version.ts. The standard library is released each time Deno is released.

We strongly suggest to always use imports with pinned version of standard library to avoid unintended changes. For example, rather than linking to the default branch of code, which may change at any time, potentially causing compilation errors or unexpected behavior:

  1. // import the latest release, this should be avoidedimport { copy } from "https://deno.land/std/fs/copy.ts";

instead, used a version of the std library which is immutable and will not change:

  1. // imports from v0.94.0 of std, never changesimport { copy } from "https://deno.land/std@0.94.0/fs/copy.ts";

Troubleshooting

Some of the modules provided in standard library use unstable Deno APIs.

Trying to run such modules without --unstable CLI flag ends up with a lot of TypeScript errors suggesting that some APIs in the Deno namespace do not exist:

  1. // main.tsimport { copy } from "https://deno.land/std@0.94.0/fs/copy.ts";
  2. copy("log.txt", "log-old.txt");
  1. $ deno run --allow-read --allow-write main.tsCompile file:///dev/deno/main.tsDownload https://deno.land/std@0.94.0/fs/copy.tsDownload https://deno.land/std@0.94.0/fs/ensure_dir.tsDownload https://deno.land/std@0.94.0/fs/_util.tserror: TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'. 'Deno.utime' is an unstable API. Did you forget to run with the '--unstable' flag? await Deno.utime(dest, statInfo.atime, statInfo.mtime); ~~~~~ at https://deno.land/std@0.94.0/fs/copy.ts:92:16
  2. TS2339 [ERROR]: Property 'utimeSync' does not exist on type 'typeof Deno'. 'Deno.utimeSync' is an unstable API. Did you forget to run with the '--unstable' flag? Deno.utimeSync(dest, statInfo.atime, statInfo.mtime); ~~~~~~~~~ at https://deno.land/std@0.94.0/fs/copy.ts:103:10

Solution to that problem requires adding --unstable flag:

  1. deno run --allow-read --allow-write --unstable main.ts

To make sure that API producing error is unstable check lib.deno.unstable.d.ts declaration.

This problem should be fixed in the near future. Feel free to omit the flag if the particular modules you depend on compile successfully without it.