npx.ps1 is incompatible with PowerShell ConstrainedLanguage mode · Issue #1404 · nvm-windows/nvm · GitHub
Skip to content

npx.ps1 is incompatible with PowerShell ConstrainedLanguage mode #1404

Closed

Description

@broll

Our Windows environment only allows PowerShell to run in ConstrainedLanguage mode.

The generated npx.ps1 script uses PowerShell features that are blocked in this mode, including:

  • [Reflection.BindingFlags]
  • Management.Automation.Language.Parser
  • Get-Member
  • Invoke-Expression

The failure occurs when running npx through the PowerShell shim. Node.js and npm are installed correctly, but npx.ps1 fails before the command can run.

Expected behavior:

npx.ps1 should work in PowerShell ConstrainedLanguage mode, or npm should provide a wrapper that does not require restricted PowerShell APIs.

Activity

  1. coreybutler commented on Sep 18, 2026

    @coreybutler
    Collaborator

    This is an upstream issue with npm, but we may still be able to do something about it.

    If you're running NVM for Windows in shim mode, the nvm-windows npx.exe shim calls the npx-cli.js file directly. In link mode, calling npx would hit the Node-provided npx.ps1 or npx.cmd files directly as you've described. Link mode is the "hands off" mode, where the version manager doesn't touch the Node installation.

    Note

    This is an upstream issue out of our control, but we could modify the Node installer to remove the npx.ps1 file at install time (in link mode). This would force npx ... to run the npx.cmd file. This capability would have to be behind a configuration setting and we'd likely only make this available in certified builds (the paid version designed to support controlled environments).

    I'm going to close this since it is an upstream issue that is mitigated via shim mode (.nodejs\npx.exe → npx-cli.js). If there is a desire for the control mentioned in the note, ping us at support@author.io.

    If you're running shim mode and still facing this, I'll reopen the issue.

    Run nvm env to determine your current mode.

    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions