{"record":{"id":"eff877f94b36c698","repo":"gatsbyjs/gatsby","slug":"the-file-path-relative-rootdir-filepath-has","errorCode":null,"errorMessage":"The file '${path.relative(rootDir, filePath)}' has both .js and .mjs variants, please use one or the other. Using .js by default.","messagePattern":"The file '(.+?)' has both \\.js and \\.mjs variants, please use one or the other\\. Using \\.js by default\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/bootstrap/resolve-js-file-path.ts","lineNumber":40,"sourceCode":"  rootDir: string\n  filePath: string\n  warn?: boolean\n}): Promise<string> {\n  const filePathWithJSExtension = filePath.endsWith(`.js`)\n    ? filePath\n    : `${filePath}.js`\n  const filePathWithMJSExtension = filePath.endsWith(`.mjs`)\n    ? filePath\n    : `${filePath}.mjs`\n\n  // Check if both variants exist\n  try {\n    if (\n      require.resolve(filePathWithJSExtension) &&\n      require.resolve(filePathWithMJSExtension)\n    ) {\n      if (warn) {\n        report.warn(\n          `The file '${path.relative(\n            rootDir,\n            filePath\n          )}' has both .js and .mjs variants, please use one or the other. Using .js by default.`\n        )\n      }\n      return filePathWithJSExtension\n    }\n  } catch (_) {\n    // Do nothing\n  }\n\n  // Check if .js variant exists\n  try {\n    if (require.resolve(filePathWithJSExtension)) {\n      return filePathWithJSExtension\n    }\n  } catch (_) {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/e85d62f1779e353eaac1753211629a26d123e26c/packages/gatsby/src/bootstrap/resolve-js-file-path.ts#L22-L58","documentation":"Emitted by resolveJSFilepath when require.resolve finds both a .js and a .mjs file for the same module base path in the project. The resolver cannot know which variant you intend, so it deterministically picks the .js file; this warning reports that ambiguity (typically an ext-to-jsx/dual-package setup in a site or plugin).","triggerScenarios":"Thrown at packages/gatsby/src/bootstrap/resolve-js-file-path.ts:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete one of the two variants (.js or .mjs) so only one resolution exists","Rename one variant to a different base name if both are genuinely needed","Configure your bundler/TS output to emit only one extension"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e85d62f1779e353eaac1753211629a26d123e26c","analyzedAt":"2026-08-26T17:50:09.662Z","contentChangedAt":"2026-08-26T17:50:09.662Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}