Frequently Asked Questions

Getting errors when type checking like cannot find namespace NodeJS

One of the modules you are using has type definitions that depend upon the NodeJS global namespace, but those types don't include the NodeJS global namespace in their types.

The quickest fix is to skip type checking. You can do this by using the --no-check flag.

Skipping type checking might not be acceptable though. You could try to load the Node types yourself.

When using npm specifiers

If you are getting this error while using npm specifiers, then add a triple slash types reference directive to your main entry point, specifying to include the types from the @types/node package:

/// <reference types="npm:@types/node">

When using CDNs

If you are getting this error when not using npm specifiers and instead while importing from npm CDNs, then you can import the @types/node types from a CDN as well.

For example from UNPKG it would look something like this:

import type {} from "https://unpkg.com/@types/node/index.d.ts";

Or from esm.sh:

import type {} from "https://esm.sh/@types/node/index.d.ts";

Or from Skypack:

import type {} from "https://cdn.skypack.dev/@types/node/index.d.ts";

You could also try to provide only specifically what the 3rd party package is missing. For example the package @aws-sdk/client-dynamodb has a dependency on the NodeJS.ProcessEnv type in its type definitions. In one of the modules of your project that imports it as a dependency, you could put something like this in there which will solve the problem:

declare global {
  namespace NodeJS {
    type ProcessEnv = Record<string, string>;

Getting type errors like cannot find document or HTMLElement

The library you are using has dependencies on the DOM. This is common for packages that are designed to run in a browser as well as server-side. By default, Deno only includes the libraries that are directly supported. Assuming the package properly identifies what environment it is running in at runtime it is "safe" to use the DOM libraries to type check the code. For more information on this, check out the Targeting Deno and the Browser section of the manual.