Current Behavior
When a target name itself contains a :, the flag-based nx run form crashes instead of running the task.
For example, with a project that has a target named test:unit:
nx run -p my-project -t test:unit --outputStyle=static --verbose
fails with:
NX parsedArgs[PROJECT_TARGET_CONFIG]?.lastIndexOf is not a function
TypeError: parsedArgs[PROJECT_TARGET_CONFIG]?.lastIndexOf is not a function
at parseRunOneOptions (.../node_modules/nx/src/command-line/run/run-one.js:105:44)
The positional form without escaping is also ambiguous:
nx run my-project:test:unit
That gets interpreted as target test with configuration unit.
The current workaround is to escape the colon in the target name:
nx run my-project:test\:unit
That works, but it is not obvious, and the -p / -t form seems like it should be the unambiguous way to invoke this.
Expected Behavior
This should work:
nx run -p my-project -t test:unit
and run the test:unit target directly.
GitHub Repo
No response
Steps to Reproduce
- Create or use any workspace with a project that has a target named
test:unit (for example an inferred script target or any custom target with : in its name).
- Run:
nx run -p my-project -t test:unit --outputStyle=static --verbose
- Observe the TypeError.
- Run:
nx run my-project:test\:unit --outputStyle=static
- Observe that the target runs successfully.
Nx Report
Node : 24.14.1
OS : darwin-arm64
Native Target : aarch64-macos
pnpm : 10.33.0
daemon : Available
nx : 22.6.3
@nx/js : 22.6.3
@nx/eslint : 22.6.3
@nx/workspace : 22.6.3
@nx/devkit : 22.6.3
@nx/eslint-plugin : 22.6.3
@nx/module-federation : 22.6.3
@nx/next : 22.6.3
@nx/react : 22.6.3
@nx/rollup : 22.6.3
@nx/vite : 22.6.3
@nx/vitest : 22.6.3
@nx/web : 22.6.3
@nx/webpack : 22.6.3
typescript : 6.0.2
Failure Output
NX parsedArgs[PROJECT_TARGET_CONFIG]?.lastIndexOf is not a function
TypeError: parsedArgs[PROJECT_TARGET_CONFIG]?.lastIndexOf is not a function
at parseRunOneOptions (.../node_modules/nx/src/command-line/run/run-one.js:105:44)
at Object.runOne (.../node_modules/nx/src/command-line/run/run-one.js:24:18)
at async ...
Notes
I hit this while moving CI jobs to colon-named targets like test:unit and test:storybook.
The escaping workaround is usable, but it feels like nx run -p <project> -t <target-with-colon> should be the supported non-ambiguous form.
Current Behavior
When a target name itself contains a
:, the flag-basednx runform crashes instead of running the task.For example, with a project that has a target named
test:unit:fails with:
The positional form without escaping is also ambiguous:
That gets interpreted as target
testwith configurationunit.The current workaround is to escape the colon in the target name:
nx run my-project:test\:unitThat works, but it is not obvious, and the
-p/-tform seems like it should be the unambiguous way to invoke this.Expected Behavior
This should work:
and run the
test:unittarget directly.GitHub Repo
No response
Steps to Reproduce
test:unit(for example an inferred script target or any custom target with:in its name).nx run my-project:test\:unit --outputStyle=staticNx Report
Failure Output
Notes
I hit this while moving CI jobs to colon-named targets like
test:unitandtest:storybook.The escaping workaround is usable, but it feels like
nx run -p <project> -t <target-with-colon>should be the supported non-ambiguous form.