简体   繁体   中英

"Firebase cannot be loading because running scripts is disabled on this system", VSCode on Windows

I have installed the firebase tools, however whenever I try to initialize it in my rootfolder, using the terminal from Vscode, I receive the following error. Why is that?

在此处输入图像描述

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

install firebase globally

and then,

firebase login
firebase init

TLDR: Just delete your firebase.ps1 file and try again

I would not recommend bypassing the execution policy on PowerShell, as it makes your system more vulnerable to malicious scripts.

Instead, simply delete the firebase.ps1 file at the location indicated by the error message and try running the command again.

Note: in case the above doesn't work, you might need to clear your npm cache by running npm cache clean --force .

Source: https://stackoverflow.com/a/54776674/1536286

Run the following at the terminal in VS Code (make sure the app is run with the option Running as Administrator as suggested by @MaylorTaylor)

Set-ExecutionPolicy RemoteSigned

Then run the script in that same console.

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

这对我有用

Open Windows Power Shell as Administrator and then run the below command to change Execution Policy setting to RemoteSigned

Set-ExecutionPolicy RemoteSigned

Now change directory to your project folder and run the following

firebase login
firebase init

Close cmd and powershell and VS Code. Then right click on VS code---RunAs Administrator and in the VS Code Terminal run the following command:

Set-ExecutionPolicy Unrestricted

Then in the same VS Code cmd run:

firebase login
firebase init

This should solve your problem. Windows now comes with an extra layer of security to protect your OS environment from random scripts running in the background without admin privilege's. Most Random Scripts(From browser engines on unverified sites and applications) are also bad for your OS,unless you are running them yourself as an admin or as a developer,provided you know what you are doing. Firebase scripts are pretty safe.

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

在您当前的工作目录中运行它,即初始化 Firebase 并运行此命令,对我有用。

Instead of setting Execution Policy. I ran windows terminal as administrator instead of VS code terminal and execute command without an issue.

Simply in VScode switch from PowerShell to cmd and type this command.

firebase login

And you will be redirected to your browser to allow Firebase CLI to access the account connected to your firebase project and then type this command.

firebase init 

That should work

In cmd it works

firebase login

firebase init

Select project

If using VScode, installing the PowerShell extension by Microsoft will solve this issue.

enter link description here

Bypassing the execution policy in PowerShell may be dangerous. I recommend to rename the file (to firebase_old.ps1 for example) or to delete it. It is much safer.

The solution for me: is that i am using Windows 11 and i used to use Windows Power Shell instead of Command Prompt

在此处输入图像描述

In case want to use Windows Power Shell you have to run this cmd first:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM