Nexmo / nexmo-cli

Nexmo CLI (Command Line Interface)
https://nexmo.com
MIT License
78 stars 52 forks source link

Windows Powershell - "running scripts is disabled on this system" when running `nexmo` #218

Open dragonmantank opened 4 years ago

dragonmantank commented 4 years ago

Steps to reproduce

On Windows 10:

Expected behavior

I should see the help output from the nexmo command.

Actual behavior

nexmo : File C:\Users\chris\AppData\Roaming\npm\nexmo.ps1 cannot be loaded because running scripts is disabled on this
system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ nexmo
+ ~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

This normally occurs when the remote script isn't trusted. I could get it to run by changing my Execution Policy to "RemoteSigned", at which point the CLI worked again:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

It looks like at some point after npm 6.9.0, npm started generating a nexmo.ps1 file to help wrap the node SDK in the event node is installed both under Powershell and Linux. This ps1 file will not run under the default "Restricted" execution policy Windows 10 ships with.

npm 6.9.0 and prior do not generate this file, and worked fine.

Other projects with this same general issue:

System configuration

Node version: 12.16.3

NPM version: Broken under 6.14.4 Works under 6.9.0

Operating system: Windows 10 Professional under Powershell