{"record":{"id":"9acd7befee708895","repo":"yarnpkg/yarn","slug":"package-1-refers-to-a-non-existing-file-0","errorCode":null,"errorMessage":"Package $1 refers to a non-existing file '$0'.","messagePattern":"Package \\$1 refers to a non-existing file '\\$0'\\.","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/resolvers/exotics/file-resolver.js","lineNumber":52,"sourceCode":"    let loc = this.loc;\n    if (!path.isAbsolute(loc)) {\n      loc = path.resolve(this.config.lockfileFolder, loc);\n    }\n\n    if (this.config.linkFileDependencies) {\n      const registry: RegistryNames = 'npm';\n      const manifest: Manifest = {_uid: '', name: '', version: '0.0.0', _registry: registry};\n      manifest._remote = {\n        type: 'link',\n        registry,\n        hash: null,\n        reference: loc,\n      };\n      manifest._uid = manifest.version;\n      return manifest;\n    }\n    if (!await fs.exists(loc)) {\n      throw new MessageError(this.reporter.lang('doesntExist', loc, this.pattern.split('@')[0]));\n    }\n\n    const manifest: Manifest = await (async () => {\n      try {\n        return await this.config.readManifest(loc, this.registry);\n      } catch (e) {\n        if (e.code === 'ENOENT') {\n          return {\n            // This is just the default, it can be overridden with key of dependencies\n            name: path.dirname(loc),\n            version: '0.0.0',\n            _uid: '0.0.0',\n            _registry: 'npm',\n          };\n        }\n\n        throw e;\n      }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/resolvers/exotics/file-resolver.js#L34-L70","documentation":"The file resolver checks fs.exists(loc) before reading a file: dependency; if the path does not exist on disk, it throws. The loc is derived from the dependency pattern; the package name is extracted for the error message.","triggerScenarios":"A package.json dependency uses file:./some-path but that path does not exist relative to the project. Checked after the symlink/shortcut path is ruled out.","commonSituations":"Project moved or renamed, breaking relative file: paths; monorepo workspace paths pointing at non-existent siblings; build artifacts referenced by file: not yet generated.","solutions":["Verify the file: path exists relative to the package.json location","Use correct relative paths (note resolution is relative to the package, not the repo root)","Ensure any build step that produces the referenced path has run before install","Switch to a workspace: protocol for monorepo internal packages"],"exampleFix":"// before (package.json)\n\"local-pkg\": \"file:./built/local-pkg\"\n// after\n\"local-pkg\": \"file:./packages/local-pkg\"","handlingStrategy":"validation","validationCode":"import * as fs from './util/fs.js';\nimport * as path from 'path';\nconst resolvedLoc = path.resolve(config.cwd, loc);\nif (!await fs.exists(resolvedLoc)) {\n  throw new Error(`file: dependency path does not exist: ${resolvedLoc}`);\n}","typeGuard":"async function fileDependencyExists(loc: string): Promise<boolean> {\n  try { await fs.access(loc); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  const manifest = await fileResolver.resolve();\n} catch (e) {\n  if (e.message.includes('non-existing file')) {\n    // correct the path or build the missing artifact\n  }\n}","preventionTips":["Verify file: paths exist before committing package.json","Run build steps that produce file: artifacts before install","Prefer the workspace: protocol for monorepo-internal packages"],"tags":["file-resolver","paths","dependencies"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}