title: electron - node.js - ng : file path\ng.ps1 cannot be loaded because running scripts is disabled on this system
body: <p>I am trying to compile a project on <code>Windows 10</code> in <code>Visual Studio Code</code>, my settings are the following:</p>
  
  <p>1) <code>npm</code> version <code>6.12</code></p>
  
  <p>2) <code>Node.js</code> version <code>12.13</code></p>
  
  <p>3) <code>Angular CLI: 8.3.19</code></p>
  
  <p>The problem I have is as soon as I try to run <code>ng serve</code> I receive the following input : <code>ng : File C:\Users\name\AppData\Roaming\npm\ng.ps1 cannot be loaded because running scripts is disabled on this system</code>. Followed by <code>For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.</code></p>
  
  <p><strong>What I tried so far</strong></p>
  
  <p><strong>1)</strong> I went on the website advised and found that <code>Set-ExecutionPolicy -ExecutionPolicy RemoteSigned</code> should be the command I have to enter in the shell. Therefore what I did was: </p>
  
  <p><code>PS C:\Users\raggi\OneDrive\Desktop\pitalkdashboard&gt; Set-ExecutionPolicy -ExecutionPolicy RemoteSigned</code></p>
  
  <p>But that led to the following error:</p>
  
  <p><code>Set-ExecutionPolicy : Access to the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell is denied. To change the execution policy for the default (LocalMachine) scope, start Windows PowerShell with the "Run as administrator" option. To change the execution policy for the current user, run "Set-ExecutionPolicy -Scope CurrentUser".</code></p>
  
  <p>And that is exactly what I did, so in order:</p>
  
  <p><code>PS C:\Users\raggi\OneDrive\Desktop\pitalkdashboard&gt; Set-ExecutionPolicy -Scope CurrentUser</code></p>
  
  <p>Below was prompted by the Shell, I only had to insert <code>RemoteSigned</code>:</p>
  
  <p><code>cmdlet Set-ExecutionPolicy at command pipeline position 1</code></p>
  
  <p><code>Supply values for the following parameters:</code></p>
  
  <p><code>ExecutionPolicy: RemoteSigned</code></p>
  
  <p>After that I tried <code>ng serve</code> to launch the whole project but received a different error, for which I am putting below a print screen as it is too long:</p>
  
  <p><img src="https://i.imgur.com/NwUhmxw.png" alt="error"></p>
  
  <p>Don't have any more ideas on going on on this route.</p>
  
  <p><strong>2)</strong> As advised <a href="https://stackoverflow.com/questions/37700536/visual-studio-code-terminal-how-to-run-a-command-with-administrator-rights">here</a> and <a href="https://stackoverflow.com/questions/49763146/electron-node-js-fs-readfilesync-requires-admin-privileges-when-electron-is">also here</a> </p>
  
  <p>I tried to access and run as <code>administrator</code> as shown in the print screen below:</p>
  
  <p><img src="https://i.imgur.com/SFUDqj9.png" alt="admin"></p>
  
  <p>but the only things I visualize on the shell is the following below (however the shell disappears right away and I only had the time to take the print screen)</p>
  
  <p><img src="https://i.imgur.com/8twnRIq.png" alt="shell2"></p>
  
  <p><strong>3)</strong> I dug more into the problem and found some additional insights such as <a href="https://www.technipages.com/fix-access-to-the-registry-key-is-denied" rel="noreferrer">this one</a> and also <a href="https://stackoverflow.com/questions/4037939/powershell-says-execution-of-scripts-is-disabled-on-this-system">this additional source</a>. However the only thing that the post was pointing out was, again, to use <code>Set-ExecutionPolicy -ExecutionPolicy RemoteSigned</code> which I tried at point 1) above.</p>
  
  <p><strong>4)</strong> After a bit more research I came across <a href="https://stackoverflow.com/questions/44958847/the-term-ng-is-not-recognized-as-the-name-of-a-cmdlet/44958882">this one</a> but unfortunately no useful information I used.</p>
  
  <p><strong>the code</strong></p>
  
  <p>Below is what I have in my <code>package.json</code> if that is useful:</p>
  
  <pre><code>{
    "name": "pi-talk-dashboard",
    "version": "0.0.0",
    "scripts": {
      "ng": "ng",
      "start": "ng serve",
      "build": "ng build",
      "test": "ng test",
      "lint": "ng lint",
      "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
      "@agm/core": "^1.0.0-beta.5",
      "@angular/animations": "^6.0.3",
      "@angular/common": "^6.0.3",
      "@angular/compiler": "^6.0.3",
      "@angular/core": "^6.0.3",
      "@angular/forms": "^6.0.3",
      "@angular/http": "^6.0.3",
      "@angular/platform-browser": "^6.0.3",
      "@angular/platform-browser-dynamic": "^6.0.3",
      "@angular/router": "^6.0.3",
      "chart.js": "^2.7.3",
      "core-js": "^2.5.4",
      "electron": "^7.1.0",
      "express": "^4.17.1",
      "moment": "^2.22.2",
      "ng2-charts": "^1.6.0",
      "rxjs": "^6.0.0",
      "zone.js": "^0.8.26"
    },
    "devDependencies": {
      "@angular-devkit/build-angular": "^0.803.17",
      "@angular/cli": "~6.0.8",
      "@angular/compiler-cli": "^6.0.3",
      "@angular/language-service": "^6.0.3",
      "@types/jasmine": "~2.8.6",
      "@types/jasminewd2": "~2.0.3",
      "@types/node": "~8.9.4",
      "codelyzer": "~4.2.1",
      "jasmine-core": "~2.99.1",
      "jasmine-spec-reporter": "~4.2.1",
      "karma": "~1.7.1",
      "karma-chrome-launcher": "~2.2.0",
      "karma-coverage-istanbul-reporter": "~2.0.0",
      "karma-jasmine": "~1.1.1",
      "karma-jasmine-html-reporter": "^0.2.2",
      "protractor": "^5.4.1",
      "ts-node": "~5.0.1",
      "tslint": "~5.9.1",
      "typescript": "~2.7.2"
    }
  }
  </code></pre>
  
  <p><strong>EDITS</strong></p>
  
  <p>After running the -ExecutionPolicy Unrestricted as admin the following script opened in <code>notepad</code> but I am not sure about its use. I am attaching both print screen and code of the file that opened:</p>
  
  <p><img src="https://i.imgur.com/VzRH8Jm.png" alt="admin"></p>
  
  <p>code is below:</p>
  
  <pre><code>#!/usr/bin/env pwsh
  $basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
  
  $exe=""
  if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
    # Fix case when both the Windows and Linux builds of Node
    # are installed in the same directory
    $exe=".exe"
  }
  $ret=0
  if (Test-Path "$basedir/node$exe") {
    &amp; "$basedir/node$exe"  "$basedir/node_modules/@angular/cli/bin/ng" $args
    $ret=$LASTEXITCODE
  } else {
    &amp; "node$exe"  "$basedir/node_modules/@angular/cli/bin/ng" $args
    $ret=$LASTEXITCODE
  }
  exit $ret
  </code></pre>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>After running on PowerShell <code>-ExecutionPolicy Unrestricted</code> nothing changed. But an error came out. <code>Data path ".builders['app-shell']" should have required property 'class'.</code>
  See print screen below</p>
  
  <p><img src="https://i.imgur.com/bQfZmhA.png" alt="powershell"></p>
  
  <p>I am running out of ideas on how to run this project and on how to solve this <code>ng serve</code> problem, any insights or guidance in another direction will be useful to solve this issue.</p>