Categories
Developer Tools How to

VS Code Scripts Disabled Error: Fix

I’ve started to enjoy using Visual Studio Code as of late, my favourite choice in Code editor (Intellisense ftw). However, if you notice that vs code scripts are disabled using the terminal, you might need a slight configuration. Specifically, if you plan on using it for running global commands.

VS Code ‘scripts is disabled’ error appears because by default, access of this sort is restricted within the powershell comand console.

You’ll have something like this in your terminal window (probably in an angry red font):

File C:\...\activate.ps1 cannot be loaded because running scripts is disabled on this system.

Here’s the fix, assuming you’re using Windows:

Use the keyboard shortcut ctrl + shift + p in Visual Studio Code. Type settings.json in the search box. Select the option: Preferences: Open Settings (JSON). In the settings.json file that appears, paste in the following:

    "terminal.integrated.profiles.windows": {
        "PowerShell": {
          "source": "PowerShell",
          "icon": "terminal-powershell",
          "args": ["-ExecutionPolicy", "Bypass"]
        }
      },
      "terminal.integrated.defaultProfile.windows": "PowerShell"

Restart Visual Studio and you should then be able to run global commands such as vue ui, php etc…

Hopefully with this fix you’ll no longer get that pesky VS Code scripts is disabled >:( error.

I just hope that the packages I use for atom, have similar equivalents in VS Code.

On a side note, I’ve found Visual Studio Code to be a great lightweight alternative to the full blown Visual Studio, which is far too feature rich for my needs. The fact that it’s Microsoft software also means that it integrates nicely with c# etc, a programming language I’m getting into these days with Unity.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.