Current Behavior
In a pnpm workspace that uses catalogs, generating a React application with the default Vite path fails if the root package.json declares vite using a catalog alias such as catalog:tooling.
The generator crashes before the app is created with this error:
NX Invalid version. Must be a string. Got type "object".
### Expected Behavior
Nx should handle pnpm catalog aliases in `package.json` without crashing during React app generation.
Acceptable outcomes would be any of the following:
- Resolve the catalog alias before semver parsing.
- Skip semver-based version branching when the version is a pnpm catalog alias.
- Fall back to a safe plugin version instead of throwing.
### Steps to Reproduce
1. Create an Nx workspace that uses pnpm catalogs.
2. In the root `package.json`, declare the relevant tooling packages using pnpm catalog aliases, for example:
```json
{
"packageManager": "pnpm@10.33.0",
"devDependencies": {
"nx": "catalog:",
"@nx/react": "catalog:",
"@nx/vite": "catalog:",
"@nx/vitest": "catalog:",
"vite": "catalog:tooling",
"vitest": "catalog:tooling",
"@vitejs/plugin-react": "catalog:tooling"
}
}
-
In pnpm-workspace.yaml, define the catalog values, for example:
catalogs:
tooling:
vite: "^7.3.2"
vitest: "^4.0.0"
"@vitejs/plugin-react": "^4.2.0"
-
Run this command:
pnpm nx generate @nx/react:application apps/activity-log --name=activity-log --e2eTestRunner=none --port=17444 --tags=scope:data-query-tool,type:app --no-interactive --dry-run --verbose
-
Observe that the generator fails with Invalid version. Must be a string. Got type "object".
Nx Report
Node : 24.8.0
OS : win32-x64
Native Target : x86_64-windows
pnpm : 10.33.0
daemon : Available
nx : 22.6.5
@nx/js : 22.6.5
@nx/eslint : 22.6.5
@nx/workspace : 22.6.5
@nx/cypress : 22.6.5
@nx/devkit : 22.6.5
@nx/eslint-plugin : 22.6.5
@nx/module-federation : 22.6.5
@nx/playwright : 22.6.5
@nx/react : 22.6.5
@nx/rollup : 22.6.5
@nx/storybook : 22.6.5
@nx/vite : 22.6.5
@nx/vitest : 22.6.5
@nx/web : 22.6.5
typescript : 5.9.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/eslint/plugin
@nx/vite/plugin
@nx/vitest
@nx/vitest
@nx/playwright/plugin
@nx/storybook/plugin
---------------------------------------
Community plugins:
@juristr/nx-tailwind-sync : 0.0.9
---------------------------------------
Cache Usage: 0.00 B / 47.59 GB
Failure Logs
## Failure Logs
NX Generating @nx/react:application
The 'setup-tailwind' generator is deprecated. Generating Tailwind configuration is no longer maintained. This generator will be removed in Nx 23.
NX Invalid version. Must be a string. Got type "object".
TypeError: Invalid version. Must be a string. Got type "object".
at new SemVer (C:\projects\PCM\pcm-ilevel-ui\node_modules\.pnpm\semver@7.7.4\node_modules\semver\classes\semver.js:21:13)
at major (C:\projects\PCM\pcm-ilevel-ui\node_modules\.pnpm\semver@7.7.4\node_modules\semver\functions\major.js:4:29)
at ensureDependencies (C:\projects\PCM\pcm-ilevel-ui\node_modules\.pnpm\@nx+vite@22.6.5_@babel+trav_e12ef34fbd107de3d1126c100a7caef7\node_modules\@nx\vite\src\utils\ensure-dependencies.js:33:62)
at viteConfigurationGeneratorInternal (C:\projects\PCM\pcm-ilevel-ui\node_modules\.pnpm\@nx+vite@22.6.5_@babel+trav_e12ef34fbd107de3d1126c100a7caef7\node_modules\@nx\vite\src\generators\configuration\configuration.js:50:61)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async setupViteConfiguration (C:\projects\PCM\pcm-ilevel-ui\node_modules\.pnpm\@nx+react@22.6.5_@babel+cor_358d6db5eafccf666e3144d67f96de6f\node_modules\@nx\react\src\generators\application\lib\bundlers\add-vite.js:26:22)
at async applicationGeneratorInternal (C:\projects\PCM\pcm-ilevel-ui\node_modules\.pnpm\@nx+react@22.6.5_@babel+cor_358d6db5eafccf666e3144d67f96de6f\node_modules\@nx\react\src\generators\application\application.js:119:9)
at async C:\projects\PCM\pcm-ilevel-ui\node_modules\.pnpm\nx@22.6.5_@swc-node+registe_a0326968ab149dd28b46b0449ceadc7b\node_modules\nx\src\command-line\generate\generate.js:252:26
at async handleErrors (C:\projects\PCM\pcm-ilevel-ui\node_modules\.pnpm\nx@22.6.5_@swc-node+registe_a0326968ab149dd28b46b0449ceadc7b\node_modules\nx\src\utils\handle-errors.js:8:24)
at async Object.handler (C:\projects\PCM\pcm-ilevel-ui\node_modules\.pnpm\nx@22.6.5_@swc-node+registe_a0326968ab149dd28b46b0449ceadc7b\node_modules\nx\src\command-line\generate\command-object.js:13:22)
Package Manager Version
pnpm 10.33.0
Operating System
Additional Information
-
I reproduced this after clearing Nx cache, removing and reinstalling node_modules, and upgrading from Nx 22.6.4 to 22.6.5.
-
This does not appear to be a corrupted install or a missing transitive dependency.
-
The issue appears to come from @nx/vite and @nx/vitest reading the literal value of devDependencies.vite from the root package.json and then passing it to semver.coerce().
-
Current installed code in @nx/vite/src/utils/ensure-dependencies.js:
const pkgJson = JSON.parse(host.read('package.json', 'utf-8'));
const viteRange = pkgJson?.devDependencies?.['vite'];
const viteMajor = viteRange ? major(coerce(viteRange)) : null;
-
The same pattern exists in @nx/vitest/src/utils/ensure-dependencies.js.
-
When viteRange is catalog:tooling, semver.coerce('catalog:tooling') returns null, and then major(null) throws.
-
In this workspace, @vitejs/plugin-react-swc is installed and --compiler=swc works as a workaround because it avoids the @vitejs/plugin-react version-selection branch.
Current Behavior
In a pnpm workspace that uses catalogs, generating a React application with the default Vite path fails if the root
package.jsondeclaresviteusing a catalog alias such ascatalog:tooling.The generator crashes before the app is created with this error:
In
pnpm-workspace.yaml, define the catalog values, for example:Run this command:
Observe that the generator fails with
Invalid version. Must be a string. Got type "object".Nx Report
Failure Logs
Package Manager Version
pnpm 10.33.0
Operating System
Additional Information
I reproduced this after clearing Nx cache, removing and reinstalling
node_modules, and upgrading from Nx22.6.4to22.6.5.This does not appear to be a corrupted install or a missing transitive dependency.
The issue appears to come from
@nx/viteand@nx/vitestreading the literal value ofdevDependencies.vitefrom the rootpackage.jsonand then passing it tosemver.coerce().Current installed code in
@nx/vite/src/utils/ensure-dependencies.js:The same pattern exists in
@nx/vitest/src/utils/ensure-dependencies.js.When
viteRangeiscatalog:tooling,semver.coerce('catalog:tooling')returnsnull, and thenmajor(null)throws.In this workspace,
@vitejs/plugin-react-swcis installed and--compiler=swcworks as a workaround because it avoids the@vitejs/plugin-reactversion-selection branch.