react/create-react-app · error · Error

You have both a tsconfig.json and a jsconfig.json. If you ar

Error message

You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.

What it means

modules.getModules detects TypeScript setup by checking for tsconfig.json and jsconfig.json existence. Both files configuring module resolution at once is ambiguous and TypeScript-dominant, so CRA refuses to continue and asks the user to remove jsconfig.json. The check is two fs.existsSync calls combined with &&.

Source

Thrown at packages/react-scripts/config/modules.js:108

    return {};
  }

  const baseUrlResolved = path.resolve(paths.appPath, baseUrl);

  if (path.relative(paths.appPath, baseUrlResolved) === '') {
    return {
      '^src/(.*)$': '<rootDir>/src/$1',
    };
  }
}

function getModules() {
  // Check if TypeScript is setup
  const hasTsConfig = fs.existsSync(paths.appTsConfig);
  const hasJsConfig = fs.existsSync(paths.appJsConfig);

  if (hasTsConfig && hasJsConfig) {
    throw new Error(
      'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.'
    );
  }

  let config;

  // If there's a tsconfig.json we assume it's a
  // TypeScript project and set up the config
  // based on tsconfig.json
  if (hasTsConfig) {
    const ts = require(resolve.sync('typescript', {
      basedir: paths.appNodeModules,
    }));
    config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config;
    // Otherwise we'll check if there is jsconfig.json
    // for non TS projects.
  } else if (hasJsConfig) {
    config = require(paths.appJsConfig);

View on GitHub (pinned to 6254386531)

Solutions

  1. If you are using TypeScript, delete jsconfig.json from the project root.
  2. If you are using plain JavaScript, delete tsconfig.json.
  3. After deleting, restart your editor/IDE to clear cached config.
  4. Add jsconfig.json to .gitignore only if intentionally JS-only, to prevent accidental re-creation alongside a TS setup.

Example fix

# before
ls
# jsconfig.json  package.json  tsconfig.json
# after
rm jsconfig.json
ls
# package.json  tsconfig.json
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
function assertSingleConfig(root = process.cwd()) {
  const hasTs = fs.existsSync(path.join(root, 'tsconfig.json'));
  const hasJs = fs.existsSync(path.join(root, 'jsconfig.json'));
  if (hasTs && hasJs) {
    throw new Error('Both tsconfig.json and jsconfig.json present. Remove one.');
  }
}
assertSingleConfig();

Type guard

const hasSingleConfig = (root) =>
  !(fs.existsSync(path.join(root, 'tsconfig.json')) &&
    fs.existsSync(path.join(root, 'jsconfig.json')));

Try / catch

try {
  require('react-scripts/config/modules').getModules();
} catch (e) {
  if (/tsconfig.json and a jsconfig.json/.test(e.message)) {
    console.error('Delete jsconfig.json if using TypeScript.');
    process.exit(1);
  }
  throw e;
}

Prevention

When it happens

Trigger: Both paths.appTsConfig (tsconfig.json) and paths.appJsConfig (jsconfig.json) exist on disk. The `hasTsConfig && hasJsConfig` branch throws before either is parsed.

Common situations: Starting a project as JavaScript (jsconfig.json auto-created by editors), then adding TypeScript (tsconfig.json) without deleting jsconfig.json. Editor extensions re-creating jsconfig.json after a TS migration. Copying a project template that includes both.

Related errors


AI-assisted analysis of react/create-react-app@6254386531 (2026-08-12). Data as JSON: /api/errors/ff540903d233e0af. Report an issue: GitHub.