{"record":{"id":"1995aa94b67db4cb","repo":"appsmithorg/appsmith","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`.","messagePattern":"Your project's `baseUrl` can only be set to `src` or `node_modules`\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/client/config/modules.js","lineNumber":44,"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    ),\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  }\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/appsmithorg/appsmith/blob/8cd9021c24cdbea1c3c12c966073708e83db60c2/app/client/config/modules.js#L26-L62","documentation":"Thrown by getAdditionalModulePaths() in config/modules.js. The function resolves the tsconfig/jsconfig compilerOptions.baseUrl relative to the project root. It silently allows 'src' and 'node_modules' (handled above this snippet) and returns null when baseUrl equals the project root. For any other directory it throws, because CRA only supports absolute imports from src or node_modules — anything else would let webpack try to transpile files outside src.","triggerScenarios":"Setting compilerOptions.baseUrl in tsconfig.json or jsconfig.json to an arbitrary folder (e.g. 'app', 'lib', './src/components') that is neither 'src', 'node_modules', nor the project root.","commonSituations":"Copying a baseUrl from another project's config; IDE auto-generating a baseUrl pointing at a custom folder; migrating a non-CRA project that used baseUrl for path resolution; pointing baseUrl at a monorepo package root.","solutions":["Set baseUrl to \"src\" (most common) so absolute imports resolve from src, e.g. import from 'Components/Button'.","Or remove the baseUrl entirely and rely on CRA's default src-rooted absolute imports.","For custom aliases, use the paths/compilerOptions.paths mapping with baseUrl 'src' instead of a custom baseUrl.","If you genuinely need a non-src root, you are outside CRA's supported model — eject or use craco/react-app-rewired to override webpack resolve.alias."],"exampleFix":"// before (tsconfig.json)\n{\n  \"compilerOptions\": { \"baseUrl\": \"./app\" }\n}\n// -> Your project's `baseUrl` can only be set to `src` or `node_modules`.\n\n// after\n{\n  \"compilerOptions\": { \"baseUrl\": \"src\" }\n}","handlingStrategy":"validation","validationCode":"const path = require('path');\nconst tsConfig = require('./tsconfig.json');\nconst allowed = new Set(['src','node_modules']);\nconst base = tsConfig.compilerOptions?.baseUrl;\nif (base && !allowed.has(path.basename(base)) && path.relative(process.cwd(), path.resolve(base)) !== '') {\n  throw new Error('baseUrl must be src or node_modules');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep baseUrl as 'src' or omit it.","For custom aliases use compilerOptions.paths with baseUrl 'src'.","Add a CI lint rule that fails if baseUrl is set to anything but src/node_modules."],"tags":["typescript","configuration","build","circular-imports","cjs"],"backgroundTag":null,"analyzedSha":"8cd9021c24cdbea1c3c12c966073708e83db60c2","analyzedAt":"2026-08-12T22:14:19.293Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}