0

so i wanted to create a extension pack for vscode, first i installed node.js then git, then i did

npm install -global yo

i got these warns

npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated readdir-scoped-modules@1.1.0: This functionality has been moved to @npmcli/fs
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs

changed 734 packages in 59s

82 packages are looking for funding

but i thought it is okay and kept going this time installing the code generator

npm install -global yo generator-code

and got these three warns:

npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated readdir-scoped-modules@1.1.0: This functionality has been moved to @npmcli/fs
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs

changed 921 packages in 7m

84 packages are looking for funding

and then after typing

yo code

it throws an error (rus, orig):

yo : Невозможно загрузить файл C:\Users\User\AppData\Roaming\npm\yo.ps1, так как выполнение сценариев отключено в этой
системе. Для получения дополнительных сведений см. about_Execution_Policies по адресу https:/go.microsoft.com/fwlink/?L
inkID=135170.
строка:1 знак:1
+ yo code
+ ~~
    + CategoryInfo          : Ошибка безопасности: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

the same error, but google-translated:

yo : Unable to upload file C:\Users\User\AppData\Roaming\npm\yo.ps1 , since script execution is disabled on this
system. For more information, see about_performing_police at https:/go.microsoft.com/fwlink/?L
inkID=135170.
string:1 sign:1
+ + code yo
+ ~~
+ + Category Information : Security Error: (:) [], Securityexception Exception
+ + Fully Qualified Error ID : Unauthorized Access

can someone help me please?

i tried reinstalling nodejs, that didnt help at all, also tried searching for other ways to create an extension pack, found nothing

phd
  • 82,685
  • 13
  • 120
  • 165
  • https://stackoverflow.com/search?q=%5Bpowershell%5D+script+execution+is+disabled+on+this+system – phd Mar 17 '23 at 11:25

1 Answers1

0

Execution of arbitrary scripts is disabled in your Windows installation, if you go to the link provided in error message you can see how to enable it, tldr (run in powershell as administrator!):

Get-ExecutionPolicy -List
# You will see a list with all Execution policy probably set to Undefined

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine

Get-ExecutionPolicy -List
# You should see that the policy for LocalMachine is set to Unrestricted
# For changes to take an effect you have to restart each shell that should use this new policy
# (so you need to close all opened vscode instances, or easier you can just restart windows)
Grekkq
  • 679
  • 6
  • 14
  • i used all the commands, i made sure that it is set to unrestricted, but i still get the following warnings while installing "yo" by npm ``` npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs npm WARN deprecated readdir-scoped-modules@1.1.0: This functionality has been moved to @npmcli/fs ``` – amawdin Mar 17 '23 at 15:29
  • Well they are just warnings so it should work anyway, you can try this [answer](https://stackoverflow.com/questions/74337166/npm-warn-deprecated-npmcli-move-file2-0-1-this-functionality-has-been-moved-t) – Grekkq Mar 31 '23 at 07:49