Search code examples
herokuvisual-studio-codeheroku-cli

Heroku won't load within Visual Studio Code


heroku : File C:\Users\mar\AppData\Roaming\npm\heroku.ps1 cannot be loaded. The file C:\Users\mar\AppData\Roaming\npm\heroku.ps1 is not digitally 
signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see 
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

This is the error I'm getting. I've tried running "heroku -v" within the cmd and it works there so I know it was installed correctly. However, when I run the same command in visual studio I get the above error. I'm running visual studio code in admin mode and I installed heroku from admin mode as well.

I also enabled developer mode in my computer settings.


Solution

  • You need to set the execution policy regardless of whether you are running in administrator mode or not for PowerShell.

    You can read more about this here

    You can also see that it's throwing an error with regards to execution policy. The error basically means that windows could not verify the identity of the user that created the script and is blocking you from running it because it may be harmful (based on the fact that it could not verify the identity of the file creator).

    This is just a counter-measure to prevent malicious scripts from running automatically.

    If you want to run the script I would suggest running

    Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
    

    and then running the Heroku commands. The above script removes restrictions on script executions on the current logged in user.