{"record":{"id":"a33e71bf03b2e9cd","repo":"denoland/deno","slug":"linking-npm-packages-requires-using-a-node-modules","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"validation","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"libs/resolver/factory.rs","lineNumber":697,"sourceCode":"        Ok(new_rc(WorkspaceExternalImportMapLoader::new(\n          self.sys().clone(),\n          self.workspace_directory()?.workspace.clone(),\n        )))\n      })\n  }\n\n  pub fn workspace_npm_link_packages(\n    &self,\n  ) -> Result<&WorkspaceNpmLinkPackagesRc, anyhow::Error> {\n    self\n      .workspace_npm_link_packages\n      .get_or_try_init(|| {\n        let workspace_dir = self.workspace_directory()?;\n        let npm_packages = WorkspaceNpmLinkPackagesRc::from_workspace(\n          workspace_dir.workspace.as_ref(),\n        );\n        if !npm_packages.0.is_empty() && !matches!(self.node_modules_dir_mode()?, NodeModulesDirMode::Auto | NodeModulesDirMode::Manual) {\n          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.\")\n        } else {\n          Ok(npm_packages)\n        }\n      })\n  }\n\n  fn has_flag_env_var(&self, name: &str) -> bool {\n    let value = self.sys.env_var_os(name);\n    match value {\n      Some(value) => value == \"1\",\n      None => false,\n    }\n  }\n}\n\n#[derive(Default)]\npub struct ResolverFactoryOptions {\n  pub compiler_options_overrides: CompilerOptionsOverrides,","sourceCodeStart":679,"sourceCodeEnd":715,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/libs/resolver/factory.rs#L679-L715","documentation":"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.","triggerScenarios":"Thrown at libs/resolver/factory.rs:697 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}