Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

893
Vistas
electron - node.js - ng : file path\ng.ps1 cannot be loaded because running scripts is disabled on this system

I am trying to compile a project on Windows 10 in Visual Studio Code, my settings are the following:

1) npm version 6.12

2) Node.js version 12.13

3) Angular CLI: 8.3.19

The problem I have is as soon as I try to run ng serve I receive the following input : ng : File C:\Users\name\AppData\Roaming\npm\ng.ps1 cannot be loaded because running scripts is disabled on this system. Followed by For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

What I tried so far

1) I went on the website advised and found that Set-ExecutionPolicy -ExecutionPolicy RemoteSigned should be the command I have to enter in the shell. Therefore what I did was:

PS C:\Users\raggi\OneDrive\Desktop\pitalkdashboard> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

But that led to the following error:

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".

And that is exactly what I did, so in order:

PS C:\Users\raggi\OneDrive\Desktop\pitalkdashboard> Set-ExecutionPolicy -Scope CurrentUser

Below was prompted by the Shell, I only had to insert RemoteSigned:

cmdlet Set-ExecutionPolicy at command pipeline position 1

Supply values for the following parameters:

ExecutionPolicy: RemoteSigned

After that I tried ng serve to launch the whole project but received a different error, for which I am putting below a print screen as it is too long:

error

Don't have any more ideas on going on on this route.

2) As advised here and also here

I tried to access and run as administrator as shown in the print screen below:

admin

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)

shell2

3) I dug more into the problem and found some additional insights such as this one and also this additional source. However the only thing that the post was pointing out was, again, to use Set-ExecutionPolicy -ExecutionPolicy RemoteSigned which I tried at point 1) above.

4) After a bit more research I came across this one but unfortunately no useful information I used.

the code

Below is what I have in my package.json if that is useful:

{
  "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"
  }
}

EDITS

After running the -ExecutionPolicy Unrestricted as admin the following script opened in notepad but I am not sure about its use. I am attaching both print screen and code of the file that opened:

admin

code is below:

#!/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") {
  & "$basedir/node$exe"  "$basedir/node_modules/@angular/cli/bin/ng" $args
  $ret=$LASTEXITCODE
} else {
  & "node$exe"  "$basedir/node_modules/@angular/cli/bin/ng" $args
  $ret=$LASTEXITCODE
}
exit $ret

EDIT 2

After running on PowerShell -ExecutionPolicy Unrestricted nothing changed. But an error came out. Data path ".builders['app-shell']" should have required property 'class'. See print screen below

powershell

I am running out of ideas on how to run this project and on how to solve this ng serve problem, any insights or guidance in another direction will be useful to solve this issue.

over 4 years ago · Santiago Trujillo
13 Respuestas
Responde la pregunta

0

  • Issue

I face the same issue and after some research I found simply bypass the restriction and launch your app thru ng server.

  • IN TERMINAL you can type below:

PS C:\Users\\\ClientApp> Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

PS C:\Users\\\ClientApp> ng serve

  • Rerun your app :

http://localhost:4200/

over 4 years ago · Santiago Trujillo Denunciar

0

You have to set your execution policy to Unrestricted not RemoteSigned. According to Set-ExecutionPolicy:

RemoteSigned. Requires that all scripts and configuration files downloaded from the Internet are signed by a trusted publisher. The default execution policy for Windows server computers.

Since 99% of all PowerShell scripts are unsigned, 99% of the time you will not be able to run them under this policy.

  1. Open PowerShell as Adminstrator.
  2. Run:

.

Set-ExecutionPolicy -ExecutionPolicy Unrestricted
over 4 years ago · Santiago Trujillo Denunciar

0

I was trying to run the electron-packager and ran into this problem

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

Fixed the problem.

over 4 years ago · Santiago Trujillo Denunciar

0

Open the file as mentioned in the error and just delete the ng.ps1 file and it will work fine..

In my case it was nodemon.ps1. I deleted it and server started.

over 4 years ago · Santiago Trujillo Denunciar

0

Open Powershell as Admin and execute the below command:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted
over 4 years ago · Santiago Trujillo Denunciar

0

adding bin folder path to environmental variable path , will work

over 4 years ago · Santiago Trujillo Denunciar

0

Try using "npx ng" instead of "ng". I get the same permissions error if I try using any "ng" command, including "ng new". Using this npm package runner solves it for me.

over 4 years ago · Santiago Trujillo Denunciar

0

Set an environmental variable path, but not working for my case. then used power shell (as administrator mode) run the below line

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

now it is working. thanks

over 4 years ago · Santiago Trujillo Denunciar

0

Run this command on your project folder

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Good luck

over 4 years ago · Santiago Trujillo Denunciar

0

I have Installed angular 12, Even I got the error like below, when I run the application using ng serve

  • CategoryInfo : SecurityError: (:) [], PSSecurityException
  • FullyQualifiedErrorId : UnauthorizedAccess

Below is the command I used to resolve the UnauthorizedAccess issue

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser
over 4 years ago · Santiago Trujillo Denunciar

0

Solved in 3 steps

  1. First, open the command prompt and run this command.

set-ExecutionPolicy RemoteSigned -Scope CurrentUser

  1. Now run the second command

Get-ExecutionPolicy

  1. To view policies, run this command

Get-ExecutionPolicy -list

then you will see

Scope ExecutionPolicy


MachinePolicy Undefined

UserPolicy Undefined

Process Undefined

CurrentUser RemoteSigned

LocalMachine Undefined

CurrentUser RemoteSigned

LocalMachine Undefined

now run command ng --version or ng serve

over 4 years ago · Santiago Trujillo Denunciar

0

I had the same issue when running Angular 12 application. Running the following script by opening Windows PowerShell as administrator mode was solved the issue.

Set-ExecutionPolicy -ExecutionPolicy Unrestricted
over 4 years ago · Santiago Trujillo Denunciar

0

Run below command in powershell.

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

If everything is okay , you will see like below screen.

enter image description here

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda