-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[BUG] Arguments are not correctly passed from CLI to npm script (npm 7, Windows, Powershell) #3136
Comments
I have noticed the following: running |
I am experiencing this same issue. npm version: 7.19.0 when running
when running
It seems a workaround currently is to include an additional can also confirm that this behavior is new to npm7, as I just upgraded from v6 recently. |
This comment has been minimized.
This comment has been minimized.
after completely uninstalling nodejs and all globally installed packages, then reinstalling the latest version of nodejs, this issue went away. |
Then it does not work in cmd or any other stuff, therefore its worse than it was (unless you are working alone on the local project and you want stick to powershell). Also experiencing the issue, for now I will switch to using cmd.exe as shell, but it's painful sometimes. |
triple dash works for me too "---" but still only powershell has this issue |
Hello all, I've run into this issue again and I decided that I would get to the bottom of it and after a few hours of spelunking I've discovered the reason for why it fails in pwsh 7. I'll be putting an explicit detail for non-experts for the reason below and explain how I figured it out, and how it is failing, as it's a combination of several behaviors. Luckily, this can be fixed fairly easily and I should be able to open a PR to resolve this unless someone beats me to it. 🙂 So, strap in because this is going to be in depth. It's a small nightmare. Feel free to skip down to "the fix" if you don't care about the reasons. 🙂 The ExplanationTo start with, pwsh itself treats Notice how the This is further compounded by pwsh treating the execution of So, when pwsh encounters The PositSo how do we get pwsh to ignore So how do we fix this? We can't let pwsh see the The FixMy current plan for the fix is a hack but should be simple: Check if I'll be submitting a PR once I have a solution (and some tests!), so it might be a day or two before it's submitted. 😅 |
Brief update: While I have a working fix for just npm/npx, the issue is more to do with how cmd-shim currently generates the .ps1 file for npm. This is used to generate every .ps1 script, not just the NPM ones installed with node, but every "binary" installed by npm. There may not be a fix for this without breaking the entire ecosystem beyond using So much for my optimism regarding this being "easily" fixable 😔 |
Hey, I do also currently have the same issue. I understand that you guys found out that the issue is with how Pwsh parses Well guess i'll just use |
It was working for me with npm 6 and node 14, switched to npm 8 and node 16 and now it's not working. The |
I've also run into this issue within my daily workflow after upgrading from node 12 to node 16 recently. We typically run cypress as an npm script as shown below.
This had always worked prior without an issue with multiple versions of PowerShell on various systems. The main difference here seems to be the upgrade to node 16 that caused this regression. For now like others I'm using the |
Hey guys. |
Hey everyone, |
So it's npm.ps1 that is broken?👀 |
@saschanaz as far as I understand it, |
Resolves #2354 Details: npm/cli#3136
Resolves #2354 Details: npm/cli#3136
This is crazy. Why Please just do the right thing and kill For anyone struggling with this, here's a quick one-liner to launch after node install:
|
Based on a Blog and Stack Overflow, we can use single quotes to pass arguments, it worked for me, example:
Blog: https://www.lloydatkinson.net/posts/2022/powershell-npm-scripts-and-silently-dropped-arguments/ |
Environment:
package.json:
npm run help
// I get help about Git (as intended)npm run git -- --help
from Powershell // I get help about npm run-scriptAs far as I can tell, the problem exists only in Powershell on Windows.
cmd and Git Bash work as intended.
Bash and pwsh on Linux also work as intended.
The problem is new to npm7 (I switched back to npm6 and it worked as intended).
The text was updated successfully, but these errors were encountered: