nx icon indicating copy to clipboard operation
nx copied to clipboard

TS error when attempting to run a workspace generator — TS5042: Option 'project' cannot be mixed with source files on a command line

Open Kris-Pelteshki opened this issue 3 years ago • 0 comments

Current Behavior

Invoking a workspace generator results in a TS error. The same behavior is also true when using the --dry-run flag

nx workspace-generator test mylib
error TS5042: Option 'project' cannot be mixed with source files on a command line.

Expected Behavior

I haven't used generators before, but I'm following the CLI from the documentation.

I assume that creating a Nx workspace, then create a workspace generator, then invoke that generator would not result in a TS error.

Steps to Reproduce

  1. npx create-nx-workspace@latest (does not seem to matter which present, from what I can tell)

  2. nx generate @nrwl/workspace:workspace-generator test image

  3. nx workspace-generator test mylib

Failure Logs

nx workspace-generator test mylib
error TS5042: Option 'project' cannot be mixed with source files on a command line.

Environment

Node : 16.14.2 OS : win32 x64 npm : 8.5.0

nx : 14.5.4 @nrwl/angular : Not Found @nrwl/cypress : Not Found @nrwl/detox : Not Found @nrwl/devkit : 14.5.4 @nrwl/eslint-plugin-nx : 14.5.4 @nrwl/express : Not Found @nrwl/jest : 14.5.4 @nrwl/js : 14.5.4 @nrwl/linter : 14.5.4 @nrwl/nest : 14.5.4 @nrwl/next : Not Found @nrwl/node : 14.5.4 @nrwl/nx-cloud : Not Found @nrwl/nx-plugin : Not Found @nrwl/react : Not Found @nrwl/react-native : Not Found @nrwl/schematics : Not Found @nrwl/storybook : Not Found @nrwl/web : Not Found @nrwl/workspace : 14.5.4 typescript : 4.7.4

Community plugins:

Kris-Pelteshki avatar Aug 06 '22 22:08 Kris-Pelteshki

I've gone ahead with the "local" nx plugin option. Everything seems to work fine!

— Thank you for the amazing tooling :)

Kris-Pelteshki avatar Aug 13 '22 09:08 Kris-Pelteshki

@Kris-Pelteshki Can you please explain ? how did you resolve "error TS5042: Option 'project' cannot be mixed" issue?

virus231 avatar Aug 31 '22 12:08 virus231

@virus231 I couldn't figure out what was the root cause for the error when I looked. So, instead of trying to use workspace generators, I looking into the option to create an nx "local" plugin.

You can write generators and executors with a plugin.

Kris-Pelteshki avatar Sep 01 '22 09:09 Kris-Pelteshki