denoland/deno · error · AnyError

Linking npm packages requires using a node_modules directory

Error message

Linking npm packages requires using a node_modules directory. Ensure you have a package.json or set the "nodeModulesDir" option to "auto" or "manual" in your workspace root deno.json.

What it means

Error "Linking npm packages requires using a node_modules directory. Ensure you have a package.json or set the "nodeModulesDir" option to "auto" or "manual" in your workspace root deno.json." thrown in denoland/deno.

Source

Thrown at libs/resolver/factory.rs:697

        Ok(new_rc(WorkspaceExternalImportMapLoader::new(
          self.sys().clone(),
          self.workspace_directory()?.workspace.clone(),
        )))
      })
  }

  pub fn workspace_npm_link_packages(
    &self,
  ) -> Result<&WorkspaceNpmLinkPackagesRc, anyhow::Error> {
    self
      .workspace_npm_link_packages
      .get_or_try_init(|| {
        let workspace_dir = self.workspace_directory()?;
        let npm_packages = WorkspaceNpmLinkPackagesRc::from_workspace(
          workspace_dir.workspace.as_ref(),
        );
        if !npm_packages.0.is_empty() && !matches!(self.node_modules_dir_mode()?, NodeModulesDirMode::Auto | NodeModulesDirMode::Manual) {
          bail!("Linking npm packages requires using a node_modules directory. Ensure you have a package.json or set the \"nodeModulesDir\" option to \"auto\" or \"manual\" in your workspace root deno.json.")
        } else {
          Ok(npm_packages)
        }
      })
  }

  fn has_flag_env_var(&self, name: &str) -> bool {
    let value = self.sys.env_var_os(name);
    match value {
      Some(value) => value == "1",
      None => false,
    }
  }
}

#[derive(Default)]
pub struct ResolverFactoryOptions {
  pub compiler_options_overrides: CompilerOptionsOverrides,

View on GitHub (pinned to 9ad36f7a2c)

When it happens

Trigger: Thrown at libs/resolver/factory.rs:697 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/a33e71bf03b2e9cd. Report an issue: GitHub.