-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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] npx opening the PowerShell script with the default editor instead of executing it. #3843
Comments
Sometimes, executing a file via the OS shell is desired behavior, though it does invite issues like this in which the file type's associated app isn't what was expected.
I agree that it would be helpful if The preferred solution is as you suggested: add the ability to specify which shell to use. Better yet, failover to another shell if the current shell encounters an exception. In the first place, the real issue that your organization requires the usage of shell scripts, yet it prohibits the use of shell scripts its products depend on. |
if your we do not attempt to run in the same shell the user is already running, rather we default to let me know if that takes care of the issue for you |
I don't understand the point of npm generating the extra files like Or am I missing something here? |
it doesn't always use from your original post:
this is the fwiw i do agree with you that it would be better if we tried to reuse the same shell you're currently in, however that would be an enormous breaking change and not something we can do lightly (like we're at least 2 semver-major releases away from making that the default) |
Stumbled into this one today per 11ty/eleventy#2875. I would say it is quite confusing (for me personally) that with our |
Is there an existing issue for this?
Current Behavior
I created a package containing a bunch of PowerShell scripts. In the
package.json
file of the package, there's such a block:The package is pushed to an npm registry.
In another location, I want to use the package and have a very simple way to be able to execute scripts from the package, let's say the
hello.ps1
that is defined as a binary in the package. So, when I installed the package using anotherpackage.json
file like this:where
tooling
is the name of the package to be installed, the node_modules/.bin folder gets populated with three files:Now, using PowerShell in the same folder where the package.json resides, I execute
npx say-hello
but I get:This program is blocked by group policy. For more information, contact your system administrator.
The computer is corporate managed and enforces a lot of policies. Looks like the
say-hello.cmd
file was attempted to be executed but failed. I know that I can execute PowerShell scripts. Why is npx defaulting to run the.cmd
file if it can detect that the shell is PowerShell? Is it possible to configure npm/npx to execute the.ps1
file instead? Trying to runnpx say-hello.ps1
command opens the script in Notepad++ in my case, instead of executing it.Expected Behavior
npx should understand that PowerShell is the current shell and executes the say-hello.ps1 file. Or at least executes it when specifying the extension of the file, like in this command:
npx say-hello.ps1
.If this is not possible, then there should be a configurable option in a .npmrc or package.json to specify which shell must be used to execute scripts.
Steps To Reproduce
No response
Environment
The text was updated successfully, but these errors were encountered: