{"record":{"id":"64b0106125eb7234","repo":"parcel-bundler/parcel","slug":"resolvers-must-return-an-absolute-path-resolver","errorCode":null,"errorMessage":"Resolvers must return an absolute path, ${resolver.name} returned: ${resultFilePath}","messagePattern":"Resolvers must return an absolute path, (.+?) returned: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/core/src/requests/PathRequest.js","lineNumber":347,"sourceCode":"          }\n\n          if (result.invalidateOnFileChange) {\n            invalidateOnFileChange.push(...result.invalidateOnFileChange);\n          }\n\n          if (result.isExcluded) {\n            return {\n              assetGroup: null,\n              invalidateOnFileCreate,\n              invalidateOnFileChange,\n              invalidateOnEnvChange,\n            };\n          }\n\n          if (result.filePath != null) {\n            let resultFilePath = result.filePath;\n            if (!path.isAbsolute(resultFilePath)) {\n              throw new Error(\n                md`Resolvers must return an absolute path, ${resolver.name} returned: ${resultFilePath}`,\n              );\n            }\n\n            return {\n              assetGroup: {\n                canDefer: result.canDefer,\n                filePath: toProjectPath(\n                  this.options.projectRoot,\n                  resultFilePath,\n                ),\n                query: result.query?.toString(),\n                sideEffects: result.sideEffects,\n                code: result.code,\n                env: dependency.env,\n                pipeline:\n                  result.pipeline === undefined\n                    ? pipeline ?? dependency.pipeline","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/core/src/requests/PathRequest.js#L329-L365","documentation":"Thrown during PathRequest resolution when a custom Resolver plugin returns a result with a filePath that is not an absolute path. Parcel's contract requires resolvers to return absolute filesystem paths so they can be reliably converted to project-relative paths via toProjectPath. The error names the offending resolver and the relative path it returned.","triggerScenarios":"Inside the resolver loop in PathRequest, when result.filePath != null and path.isAbsolute(resultFilePath) is false. The resolver plugin returned a relative path (e.g., './foo.js' or 'foo.js') instead of an absolute one (e.g., '/project/src/foo.js').","commonSituations":"Writing a custom Parcel resolver plugin and returning a relative path by mistake; resolver uses path.join instead of path.resolve; resolver returns the module specifier as-is without full resolution; bug in a third-party resolver plugin after an API change.","solutions":["In your resolver plugin, use path.resolve() to ensure the returned filePath is absolute before returning.","Use options.inputFS.realpath() or the filesystem API to get an absolute resolved path.","Check the resolver plugin API docs — ResolveResult.filePath must be an absolute path.","If using a third-party resolver, check for updates or file an issue with the plugin author.","Add a defensive path.isAbsolute() check in your resolver before returning."],"exampleFix":"// before — custom resolver plugin\nexport default {\n  async resolve({specifier, dependency}) {\n    return { filePath: `./src/${specifier}` }; // relative!\n  }\n};\n\n// after\nimport path from 'path';\nexport default {\n  async resolve({specifier, dependency, options}) {\n    const resolved = path.resolve(options.projectRoot, 'src', specifier);\n    return { filePath: resolved };\n  }\n};","handlingStrategy":"type-guard","validationCode":"const path = require('path');\n// In your resolver plugin, validate before returning\nfunction validateResolverResult(result, resolverName) {\n  if (result.filePath != null && !path.isAbsolute(result.filePath)) {\n    throw new Error(`[${resolverName}] Resolver must return an absolute path, got: ${result.filePath}`);\n  }\n}","typeGuard":"const path = require('path');\nfunction isResolveResultWithValidPath(result) {\n  return result == null\n    || result.filePath == null\n    || (typeof result.filePath === 'string' && path.isAbsolute(result.filePath));\n}","tryCatchPattern":null,"preventionTips":["Always use path.resolve() to produce absolute paths in resolver plugins.","Add a path.isAbsolute() assertion in your resolver before returning the result.","Review the Resolver plugin API contract — filePath must be absolute."],"tags":["resolver","plugin","absolute-path","dependency-resolution"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}