Repository: nodejs/node
Pull request: tools: install npm PowerShell scripts on Windows

npm 9.8.0 added PowerShell scripts that should be installed alongside the cmd and shell scripts on Windows.

All current versions of Node.js ship with npm@10 so this change should be safe to land.

I am not well versed in Windows development so I am not sure how this change should tested, and would like pointers on how to best to that.

I also want to add that there have been requests on the npm repo that PowerShell be made the default (https://github.com/npm/cli/issues/6789). From my understanding, that is up to a user configuration but will now be possible by including these files. I plan to close that issue if this is merged unless there is follow-up work to somehow change the default which I think would need a different discussion.

Closes: https://github.com/nodejs/node/issues/48471
Ref: https://github.com/npm/cli/pull/6548



<!--
Before submitting a pull request, please read:

- the CONTRIBUTING guide at https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md
- the commit message formatting guidelines at
  https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#commit-message-guidelines

For code changes:
1. Include tests for any bug fixes or new features.
2. Update documentation if relevant.
3. Ensure that `make -j4 test` (UNIX), or `vcbuild test` (Windows) passes.

If you believe this PR should be highlighted in the Node.js CHANGELOG
please add the `notable-change` label.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
-->


Changed files:
filename: tools/msvs/msi/nodemsi/product.wxs
patch: @@ -88,8 +88,10 @@
              Description="!(loc.npm_Description)">
       <ComponentRef Id="NpmCmdScript"/>
       <ComponentRef Id="NpmBashScript"/>
+      <ComponentRef Id="NpmPowerShellScript"/>
       <ComponentRef Id="NpxCmdScript"/>
       <ComponentRef Id="NpxBashScript"/>
+      <ComponentRef Id="NpxPowerShellScript"/>
       <ComponentRef Id="NpmConfigurationFile"/>
       <ComponentRef Id="SetInstallDirPermission" />
       <ComponentGroupRef Id="NpmSourceFiles"/>
@@ -224,6 +226,10 @@
         <File Id="npm.sh" KeyPath="yes" Source="$(var.NpmSourceDir)\bin\npm"/>
       </Component>
 
+      <Component Id="NpmPowerShellScript">
+        <File Id="npm.ps1" KeyPath="yes" Source="$(var.NpmSourceDir)\bin\npm.ps1"/>
+      </Component>
+
       <Component Id="NpxCmdScript">
         <File Id="npx.cmd" KeyPath="yes" Source="$(var.NpmSourceDir)\bin\npx.cmd"/>
       </Component>
@@ -232,6 +238,10 @@
         <File Id="npx.sh" KeyPath="yes" Source="$(var.NpmSourceDir)\bin\npx"/>
       </Component>
 
+      <Component Id="NpxPowerShellScript">
+        <File Id="npx.ps1" KeyPath="yes" Source="$(var.NpmSourceDir)\bin\npx.ps1"/>
+      </Component>
+
       <Directory Id="NodeModulesFolder" Name="node_modules">
         <Directory Id="NpmFolder" Name="npm">
           <Component Id="NpmConfigurationFile">

filename: vcbuild.bat
patch: @@ -406,6 +406,10 @@ if not defined nonpm (
   if errorlevel 1 echo Cannot copy npx && goto package_error
   copy /Y ..\deps\npm\bin\npx.cmd %TARGET_NAME%\ > nul
   if errorlevel 1 echo Cannot copy npx.cmd && goto package_error
+  copy /Y ..\deps\npm\bin\npm.ps1 %TARGET_NAME%\ > nul
+  if errorlevel 1 echo Cannot copy npm.ps1 && goto package_error
+  copy /Y ..\deps\npm\bin\npx.ps1 %TARGET_NAME%\ > nul
+  if errorlevel 1 echo Cannot copy npx.ps1 && goto package_error
 )
 
 if not defined nocorepack (