Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run-many appends a "--" argument when invoking packages' scripts #10111

Closed
pepicrft opened this issue May 3, 2022 · 8 comments · Fixed by #10305
Closed

run-many appends a "--" argument when invoking packages' scripts #10111

pepicrft opened this issue May 3, 2022 · 8 comments · Fixed by #10305
Labels

Comments

@pepicrft
Copy link

pepicrft commented May 3, 2022

Current Behavior

In a monorepo where each package has a tsc script to run the Typescript checker, when I run tsc through Nx using this command:

nx run-many --target=tsc --all --skip-nx-cache

Nx appends -- when it invokes the scripts, and that results in the following error:

> nx-bug@1.0.0 tsc /Users/pepicrft/Downloads/nx-bug
> nx run-many --target=tsc --all --skip-nx-cache



    ✖  nx run project:tsc
       > project@1.0.0 tsc /Users/pepicrft/Downloads/nx-bug/packages/project
       > tsc -p './tsconfig.json' "--"
       
       error TS5023: Unknown compiler option '--'.

Expected Behavior

I'd expect Nx to invoke the script as it is declared in the package without appending additional arguments.

Steps to Reproduce

  1. Download this project nx-bug.zip
  2. Install dependencies pnpm install.
  3. Run pnpm run tsc

Failure Logs

The code is included above

Environment

Node : 16.13.2
   OS   : darwin arm64
   pnpm : 7.0.0
   
   nx : 14.0.5
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.0.5
   @nrwl/eslint-plugin-nx : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 14.0.5
   @nrwl/js : Not Found
   @nrwl/linter : 14.0.5
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @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.0.5
   typescript : 4.6.4
   rxjs : 6.6.7
   ---------------------------------------
   Community plugins:
@AgentEnder AgentEnder added the scope: core core nx functionality label May 3, 2022
@simpson-du
Copy link

I am getting the same issue. Is there any easy fix or walk around?

@pepicrft
Copy link
Author

pepicrft commented May 4, 2022

I couldn't find any 😅

@kevinsperrine
Copy link

kevinsperrine commented May 4, 2022

I worked around it by simply adding an && echo to the end of my tsc commands... ie: "build": "node scripts/build.js && tsc --declaration --emitDeclarationOnly && echo"

@pionxzh
Copy link

pionxzh commented May 5, 2022

PNPM recently released V7, which changed some behavior about the argument.
My current workaround is locking the PNPM version to 6.

npm install -g pnpm@latest-6

not sure is this PR pnpm/pnpm#4290 caused the issue 🤔

Methuselah96 added a commit to Methuselah96/nx that referenced this issue May 16, 2022
Starting in pnpm v7 all command line arguments after the script name are passed to a script's arguments when using `pnpm run <script>`, including `--`. This can cause problems when there are no command line arguments, because it will pass `--` without anything following, which some scripts can't handle. In order to preserve the old functionality, we check if the pnpm version is less than 7.0.0. If it is, we include `--` before the args, otherwise we don't.

Closes nrwl#10111
@melMass
Copy link

melMass commented May 16, 2022

I have the exact same issue/setup (pnpm v7), but for me it is triggered from a @nrwl/workspace:run-script with no arguments.... So none of the suggested solution seems to fit my case. Thinking about dropping pnpm even if I like it a lot, the v7 has been only issues for me

@Methuselah96
Copy link
Contributor

@melMass I just created a PR to fix this, so maybe you can hold on for a little longer. :)

Methuselah96 added a commit to Methuselah96/nx that referenced this issue May 16, 2022
Starting in pnpm v7 all command line arguments after the script name are passed to a script's arguments when using `pnpm run <script>`, including `--`. This can cause problems when there are no command line arguments, because it will pass `--` without anything following, which some scripts can't handle. In order to preserve the old functionality, we check if the pnpm version is less than 7.0.0. If it is, we include `--` before the args, otherwise we don't.

Closes nrwl#10111
@melMass
Copy link

melMass commented May 16, 2022

Ahhh thanks, reading you PR I actually realize I misinterpreted the issue.
I think it's still not a logical default but I understand their reasoning

AgentEnder pushed a commit that referenced this issue May 16, 2022
Starting in pnpm v7 all command line arguments after the script name are passed to a script's arguments when using `pnpm run <script>`, including `--`. This can cause problems when there are no command line arguments, because it will pass `--` without anything following, which some scripts can't handle. In order to preserve the old functionality, we check if the pnpm version is less than 7.0.0. If it is, we include `--` before the args, otherwise we don't.

Closes #10111
seanwuapps added a commit to getgoui/go-ui that referenced this issue Sep 8, 2022
@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants