{"record":{"id":"3b65ceae9d937bbc","repo":"react/create-react-app","slug":"your-project-s-baseurl-can-only-be-set-to-src","errorCode":null,"errorMessage":"Your project's `baseUrl` can only be set to `src` or `node_modules`. Create React App does not support other values at this time.","messagePattern":"Your project's `baseUrl` can only be set to `src` or `node_modules`\\. Create React App does not support other values at this time\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-scripts/config/modules.js","lineNumber":52,"sourceCode":"    return null;\n  }\n\n  // Allow the user set the `baseUrl` to `appSrc`.\n  if (path.relative(paths.appSrc, baseUrlResolved) === '') {\n    return [paths.appSrc];\n  }\n\n  // If the path is equal to the root directory we ignore it here.\n  // We don't want to allow importing from the root directly as source files are\n  // not transpiled outside of `src`. We do allow importing them with the\n  // absolute path (e.g. `src/Components/Button.js`) but we set that up with\n  // an alias.\n  if (path.relative(paths.appPath, baseUrlResolved) === '') {\n    return null;\n  }\n\n  // Otherwise, throw an error.\n  throw new Error(\n    chalk.red.bold(\n      \"Your project's `baseUrl` can only be set to `src` or `node_modules`.\" +\n        ' Create React App does not support other values at this time.'\n    )\n  );\n}\n\n/**\n * Get webpack aliases based on the baseUrl of a compilerOptions object.\n *\n * @param {*} options\n */\nfunction getWebpackAliases(options = {}) {\n  const baseUrl = options.baseUrl;\n\n  if (!baseUrl) {\n    return {};\n  }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/react/create-react-app/blob/6254386531d263688ccfa542d0e628fbc0de0b28/packages/react-scripts/config/modules.js#L34-L70","documentation":"modules.getModules resolves the `baseUrl` from tsconfig.json/jsconfig.json compilerOptions relative to the project path. CRA only supports `src` or `node_modules` as baseUrl because source outside `src` is not transpiled. Any other resolved baseUrl (that isn't the project root, which is ignored) triggers this error.","triggerScenarios":"Setting `compilerOptions.baseUrl` in tsconfig.json or jsconfig.json to a directory other than `src`, `node_modules`, or the project root. The resolver computes baseUrlResolved, the relative path is non-empty and not 'src'/'node_modules', so the final throw runs.","commonSituations":"Copying a tsconfig from a non-CRA project that points baseUrl at `.` or a custom folder. Adding path mappings that imply a different baseUrl. Ejecting and bringing in outside conventions. IDE auto-generation of jsconfig with baseUrl='.'.","solutions":["Set baseUrl to 'src' (most common CRA setup): `{ \"compilerOptions\": { \"baseUrl\": \"src\" } }`.","Or remove baseUrl entirely if you don't need non-relative imports.","If you need path aliases, keep baseUrl='src' and add `paths` mappings relative to it.","Ensure baseUrl is not set to '.', '..', or a custom folder name."],"exampleFix":"// before  (tsconfig.json)\n{\n  \"compilerOptions\": { \"baseUrl\": \".\", \"paths\": { \"@/*\": [\"src/*\"] } }\n}\n// after\n{\n  \"compilerOptions\": { \"baseUrl\": \"src\", \"paths\": { \"@/*\": [\"./*\"] } }\n}","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst path = require('path');\nconst ALLOWED = ['src', 'node_modules'];\nfunction validateBaseUrl(tsConfigPath = 'tsconfig.json') {\n  const cfg = JSON.parse(fs.readFileSync(tsConfigPath, 'utf8'));\n  const baseUrl = cfg && cfg.compilerOptions && cfg.compilerOptions.baseUrl;\n  if (baseUrl && !ALLOWED.includes(baseUrl) && baseUrl !== '.') {\n    throw new Error(`baseUrl '${baseUrl}' not supported by CRA. Use 'src' or 'node_modules'.`);\n  }\n}\nvalidateBaseUrl();","typeGuard":"const isAllowedBaseUrl = (b) =>\n  b === undefined || b === 'src' || b === 'node_modules' || b === '.';","tryCatchPattern":"try {\n  require('react-scripts/config/modules').getModules();\n} catch (e) {\n  if (/baseUrl/.test(e.message)) {\n    console.error('Set tsconfig/jsconfig baseUrl to src or node_modules.');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Keep baseUrl as 'src' in CRA tsconfig/jsconfig.","When copying a tsconfig from another project, reset baseUrl.","Run `npx tsc --noEmit` after editing tsconfig to catch config errors early.","Document your supported baseUrl in the project README."],"tags":["typescript","config","baseurl","jsconfig","modules"],"backgroundTag":null,"analyzedSha":"6254386531d263688ccfa542d0e628fbc0de0b28","analyzedAt":"2026-08-12T22:55:01.751Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}