bug: --import-alias flag crashes with TypeError when used in CI mode
Provide environment information
System: OS: macOS 26.2 CPU: Unknown Memory: 122.91 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 24.4.1 - /opt/homebrew/bin/node npm: 11.4.2 - /opt/homebrew/bin/npm pnpm: 10.8.0 - /opt/homebrew/bin/pnpm
Describe the bug
Using the --import-alias (or -i) flag in CI mode causes a TypeError: i.replace is not a function crash after the boilerplate is successfully installed.
The issue is in cli/src/helpers/setImportAlias.ts (line 24-25), where .replace() is called on the importAlias value. Commander parses the --import-alias option with an optional value ([alias]), which can result in the value being true (boolean) instead of a string, causing the crash.
Expected behavior: passing --import-alias "@/" should set the import alias to @/ without errors.
Reproduction repo
No repo needed — this is reproducible with any fresh scaffold using the published CLI.
To reproduce
- Run the following command:
pnpm dlx create-t3-app@latest my-app --CI --tailwind --appRouter --eslint --import-alias "@/"- The CLI scaffolds successfully and installs boilerplate, but then crashes:
Using: pnpm
✔ my-app scaffolded successfully!
Adding boilerplate...
✔ Successfully setup boilerplate for tailwind
✔ Successfully setup boilerplate for envVariables
✔ Successfully setup boilerplate for eslint
Aborting installation...
TypeError: i.replace is not a functionThe same happens with the short flag
-i "@/".Without
--import-alias, the command works fine:
pnpm dlx create-t3-app@latest my-app --CI --tailwind --appRouter --eslintAdditional information
[this is AI]
The root cause is in cli/src/cli/index.ts line 147, where the Commander option is defined as:
.option(
"-i, --import-alias [alias]",
"Explicitly tell the CLI to use a custom import alias",
defaultOptions.flags.importAlias
)The [alias] (optional value) syntax allows Commander to return true instead of the actual string value in some cases. Then in cli/src/helpers/setImportAlias.ts:
const normalizedImportAlias = importAlias
.replace(/\*/g, "")
.replace(/[^/]$/, "$&/");true.replace() throws TypeError.
Possible fixes:
- Change
[alias]to<alias>(required value) in the Commander option definition - Add defensive type checking before calling
.replace()
Source: t3-oss/create-t3-app