DEV Community

Cover image for Fixing PowerShell Execution Policy Errors for Node.js & TypeScript
Farrukh Saeed
Farrukh Saeed

Posted on

Fixing PowerShell Execution Policy Errors for Node.js & TypeScript

A Developer's Quick Guide to Setting Up a Seamless Windows Environment for TypeScript and NodeJS.

Every developer hits this wall eventually: You try to run an npm script or the TypeScript compiler (tsc), and PowerShell greets you with a red block of text saying "Scripts are disabled on this system." Even worse, you try to fix it, and you get an "Access to the registry key is denied" error.

🔍 The Problem
By default, Windows restricts script execution for security. When you try to change the LocalMachine policy without high-level Admin rights, the system blocks you from touching the Registry.

✅ The Solution
You don't need to fight the "LocalMachine" registry. By targeting the CurrentUser scope, you can unlock your terminal immediately without needing "System" permissions.

🛠️ The Ultimate Setup Checklist
Copy and paste these commands into your VS Code terminal to get everything running smoothly.

  1. Unlock Script Execution (The "Access Denied" Fix) Run this first to allow npm and tsc to run:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force

  1. Verify Your Environment Now that the path is clear, check your versions to ensure everything is linked correctly:

node -v — Checks Node.js version

npm -v — Checks Node Package Manager version

tsc -version — Checks TypeScript Compiler version

  1. Global TypeScript Installation If tsc isn't recognized yet, install it globally:

npm install -g typescript

  1. Fresh Project Initialization Start your TypeScript journey with these two essentials:

npm init -y — Creates your package.json

tsc --init — Creates your tsconfig.json

💡 Pro-Tip for New Developers
If you are still seeing the error after running the commands, restart VS Code. The terminal needs a fresh start to "see" the new permissions you just granted it.

WebDevelopment #TypeScript #NodeJS #ProgrammingTips #CodeNewbie #WindowsDev

Top comments (0)