how to fix firebase "command not found" error - firebase

Hi I have this problem when attempting to add firebase package, getting the error below...
found 385 vulnerabilities (366 low, 7 moderate, 12 high)
run `npm audit fix`` to fix them, or `nom audit` for details
PS D: \Downloads\ codecanyon-G8bOFJ14-superstore-grocery-store-super-shop-management-pos\main-files\superstore-1.1> firebase init functions
firebase: The term 'firebase' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ firebase init functions
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (firebase:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

It looks like you didn't install the Firebase CLI yet.
If you have NPM installed locally, you can install the Firebase CLI with:
npm install firebase-tools -g
Or you can use the pre-built binary for Windows that's linked from the installation instructions. If you're not too comfortable with NPM yet, I recommend this as an easier way to get started.

npm config get prefix
In my case it returns a path C:\Program Files\Git\usr\local. In your case it may be return different path. Then go to the path and find node_modules -> npm and then copy the path.
Go to path C:\Program Files\Git\usr\local\node_modules\npm
Clikedit the system environment variable
Click environment variable
From the bottom system variable find the path
click edit in the path variable
Click new and paste the path point 3 in my case
Finally click ok and close command line
Reopen command line and type firebase --version. It will then return the version you have install.

Related

Sanity init Error, not creating a new project

So I'm a beginner with Sanity.IO and what happened was when I first created my first project everything went perfect, but I accidently deleted some important files in my VS-code which crashed my site which forced me to start over but now
sanity init
is not starting a new project. This is the error I'm receiving:
`
You're setting up a Sanity.io project!
We'll make sure you're logged in with Sanity.io.
Then, we'll install a Sanity Studio for your project.
Press ctrl + C at any time to quit.
Looks like you already have a Sanity-account. Sweet!
Error: Failed to communicate with the Sanity API:
read ECONNRESET
at C:/Users/xxx/AppData/Roaming/npm/node_modules/#sanity/cli/bin/sanity-cli.js:4860:4515
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async e.default (C:/Users/xxx/AppData/Roaming/npm/node_modules/#sanity/cli/bin/sanity-cli.js:4860:4
`
I have deleted my project from Sanity.IO studio but still I'm receiving the same error.
I have tried the following steps:
npm install -g #sanity/cli
sanity init
I get the same error.
npm install -g #sanity/cli
sanity install
sanity init
I get the same error.
I have also tried
npx install --global #sanity/cli
npx #sanity/cli init
I get the same error. I can't create a project.
Also if I try sanity logout it gives me error:
Failed to communicate with the Sanity API:
read ECONNRESET
I looking at every google link to find any solution but I have not.

flutterfire : The term 'flutterfire' is not recognized as the name of a cmdlet, function, script file, or operable program

I am getting this error when I run "dart pub global activate flutterfire_cli" :
Activated flutterfire_cli 0.1.1+2. Package flutterfire_cli is
currently active at version 0.1.1+2. Resolving dependencies... The
package flutterfire_cli is already activated at newest available
version. To recompile executables, first-run dart pub global deactivate flutterfire_cli. Installed executable flutterfire.
Warning: Pub installs executables into
C:\Users\PC\AppData\Local\Pub\Cache\bin, which is not on your path.
You can fix that by adding that directory to your system's "Path"
environment variable. A web search for "configure windows path" will
show you how
I have added this to my user path but I am still getting this error.
I checked for solutionsto similar problems which suggested I restart the windows or vs code or terminal - I did all three but it is still not working .
I ran in cmd in that it did not give the warning but when I ran flutterfire configure . It gave this error:
"FirebaseCommandException: An error occured on the Firebase CLI when
attempting to run a command. COMMAND: firebase --version ERROR: The
FlutterFire CLI currently requires the official Firebase CLI to also
be installed, see
https://firebase.google.com/docs/cli#install_the_firebase_cli for how
to install it."
running firebase --version gave this error:
'firebase' is not recognized as an internal or external command,
operable program or batch file
This should not be happening as I did connect my app to firebase console.
What worked for me is instead of typing
flutterfire I use flutterfire.bat, e.g. flutterfire.bat configure, that way the command works in the git bash with windows.
You have to add Flutter SDK path to your system environment. The error is arising because your system is not able to find the folder where you have installed Flutter in your system.
You may refer to the Stackoverflow case for the steps on how to set path for the system environment.
Alternatively, you may also refer to the video link.
If you have windows 10. Do not use firebase-tools-instant-win.exe its a trap!
Add Paths to System Variables. Don't forget to change to your username in YOU-USER-NAME
C:\Users\YOU-USER-NAME\AppData\Local\Pub\Cache\bin
C:\Users\YOU-USER-NAME\AppData\Roaming\npm
Next you can execute anywhere (in cmd or firebase-tools-instant-win.exe)
firebase login
npm install -g firebase-tools
dart pub global activate flutterfire_cli
Next you open only cmd.exe command promt and go to the root of your project.
cd c:\PATH-TO-YOU-PROJECT
flutterfire configure

How to install unofficial Firebase extension

Looking for information on steps to install the unofficial firestore-nlp-extension, link below.
https://github.com/FirebaseExtended/firestore-nlp-extension
I read the firestore docs but did not see instructions to install a "custom" extension.
Any help is appreciated!
You need to install the extension from a local source but this was available during the alpha and the below link is no longer working
https://firebase.google.com/docs/extensions/alpha/install-extensions_community#install
The specific extension does not seem to be available on the Firebase system:
Error: The extension reference
'firebase/firestore-natural-language-processing#latest' doesn't exist.
This could happen for two reasons: -The publisher ID 'firebase'
doesn't exist or could be misspelled -The name of the extension
version 'firestore-natural-language-processing#latest' doesn't exist
or could be misspelled
For the current beta from the cli tool I found the following:
First, clone the git repo of the extension:
git clone git#github.com:FirebaseExtended/firestore-nlp-extension.git
then run the following commands to build the project:
cd firestore-nlp-extension/functions
yarn add -D rimraf
yarn build
cd ../..
and then to install this extension, run:
firebase ext:install ./firestore-nlp-extension --project=YOUR_PROJECT
if you get a path error you might need to find the right path such as:
firebase ext:install ./firestore-nlp-extension/functions --project=YOUR_PROJECT

VSC PowerShell. After npm updating packages .ps1 cannot be loaded because running scripts is disabled on this system

I design websites in VSC and PowerShell is my default terminal.
After updating and deploying a website to firebase earlier, I was prompted to update firebase tools - which I did using npm. Immediately after I cannot run/access any firebase scripts wthout the folllowing error:
firebase : File C:\Users\mada7\AppData\Roaming\npm\firebase.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1
firebase
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
I've spent a few hours searching around and can't find a solid answer the problem. Many threads are several years old and I find it bizarre I've not had this problem in the past year until today.
I can still access firebase scripts if I set my default terminal to cmd.
Assuming the problem was related to firebase-tools I've carried on working but have now updated vue.js and get the error again when trying to run any vue commands in powershell:
vue : File C:\Users\mada7\AppData\Roaming\npm\vue.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1
vue
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
VSCode Version:
Version: 1.37.1 (user setup)
Commit: f06011a
Date: 2019-08-15T16:17:55.855Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.18362
OS Version:
Windows 10 Home
Version - 1903
OS build - 18362.295
I've been reading around and seen many threads around permissions for scripts, but I haven't changed any - indeed the PowerShell scripts worked right up until I updated my packages. No other settings touched in the mean time. I don't want to be changing PowerShell settings unnecessarily.
Just delete firebase.ps1 file:
File C:\Users\<your account>\AppData\Roaming\npm\firebase.ps1
This is a powershell security policy, to fix it, run Powershell as administrator and run the following
PS C:\> Set-ExecutionPolicy RemoteSigned
If you don't want to run the command as an administrator but just for the current user, you can add a scope like below
PS C:\> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
The stricter the policy, the more secure your system becomes.
You can change RemoteSigned to other options like: Restricted, AllSigned, RemoteSigned, Unrestricted
Source: https://tecadmin.net/powershell-running-scripts-is-disabled-system/
Alternatively you can modify C:\Program Files\PowerShell\7\powershell.config.json using a text editor and add or modify the following section.
{
....
"Microsoft.PowerShell:ExecutionPolicy": "RemoteSigned"
}
A little clarification: when you run PowerShell as Admin, in most cases you don't need to note a path. Just type:
Set-ExecutionPolicy RemoteSigned
then press "A", then "Enter"
Also, one thing worth mentioning is that you need to open PowerShell as Admin and then change the policy like so.
PS C:\> Set-ExecutionPolicy RemoteSigned
Reference - Using the Set-ExecutionPolicy Cmdlet
I didn't have any problem with npm but the same problem is in the using yarn on windows.
In my case, I deleted yarn.ps1 and it worked fine for me:
File path:
C:\Users\<your account>\AppData\Roaming\npm\yarn.ps1
This could be due to the current user having an undefined ExecutionPolicy.
You could try the following
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
For those who work with VS Code and get the about_Execution_Policies error. In my case with the command ncu -u (npm-check-updates).
Try it with CMD:
Simply execute the command in CMD again.
If this works, the security settings can remain as they are.
search for powershell
right click and run as administration
run this simple command Set-ExecutionPolicy RemoteSigned
Press A And Enter
go to code and run yarn add <YOUR_MODULE>
press Enter.
congratulations now it would be done.
I also had this problem in the powershell and i used the following :
then i again installed the serve package.
Set-ExecutionPolicy -Scope CurrentUser
and then i chose Unrestricted and gave serve command and it worked.
File C:\Users\xxxx\AppData\Roaming\npm\vue.ps1 cannot be loaded because running scripts is disabled on this system.
I had the same error message with vue.
After running the below command successfully
npm install -g #vue/cli
when i ran commands like vue or vue --version, i received that error message.
This is how i fixed it:
I pressed the buttons windows + E, clicked view, checked hidden items.
Then, i went to C:\Users\xxxx\AppData\Roaming\npm folder and deleted the vue file of type 'windows powershell script'.
After that, i ran the commands vue and vue --version succesfully.
Hope this helps.
Instead of using PowerShell and changing its security settings, you can simply use cmd instead. It will not give an error and your all commands will run smoothly.
Remember PowerShell is stronger and sensitive. So, Microsoft by default disables running .ps1 files as it can cause a security issue and harm your pc. So, that's why you should try to use cmd instead of changing PowerShell security.
Open Powershell from your VS code and then execute this command on that:
set-ExecutionPolicy RemoteSigned -Scope CurrentUser
this worked for me. it will ask you for CLI authentication.
Open Powershell and execute this command:
set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Delete firebase.ps1 located in:
C:\Users\<your account>\AppData\Roaming\npm\
In case you don't have firebase.ps1 delete vue.ps1
If you have this issue in VS Code, close PowerShell terminal and open a Command Prompt terminal instead.
PS C:\> Set-ExecutionPolicy RemoteSigned
It's works for me
I don't know if it can help with Firebase but I had a similar problem installing Vue with *>npm install -g #vue/cli* .
Long story short:
I deleted vue.ps1 from C:\Users\XXX\AppData\Roaming\npm\ and installed it locally (without -g) from powershell terminal inside VsCode *>npm install #vue/cli*.
After that I could use Vue commands without problems.
Just delete Power Shell file:
C:\Users\<your account>\AppData\Roaming\npm\**vue**
Delete this last vue file, extension of this file is power shall
after delete run command it's work.
On a computer with German as the default language the error might look like:
vue : Die Datei "C:\Program Files\nodejs\vue.ps1" kann nicht geladen werden, da die Ausführung von Skripts auf diesem System deaktiviert ist. Weitere Informationen finden Sie unter "about_Execution_Policies"
(https:/go.microsoft.com/fwlink/?LinkID=135170).
In Zeile:1 Zeichen:1
+ vue --version
+ ~~~
+ CategoryInfo : Sicherheitsfehler: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
I had to search for "vue" "PSSecurityException" to find this thread.
I installed a new node version with nvm-windows. Then I installed vue-cli. After that a simple vue --version led to the error above.
It seems like the removal of the vue.ps1 file helped to resolve my problem like some users suggested above.
I had a similar issue during installation of grunt and yarn.
"yarn : File C:\AppData\Roaming\npm\yarn.ps1 cannot be loaded. The file C:\AppData\Roaming\npm\yarn.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and
setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170."
When I checked the AppData\Roaming\npm* folder, I could see grunt script being generated as:
Windows Command Script
Windows Powershell Script
Upon deletion of the powershell script, the error was gone.
Just open cmd as administrator and go to your project
then execute your firebase command

Why is Visual Studio looking for my gulpfile in the wrong folder?

Backstory
I've been trying to set up a project in Visual Studio, which uses GulpJS to compile Sass. I was told that VS should automatically recognize the package.json inside a project and run npm install, but I had to do that manually through a command line. Even then, when I opened Task Runner Explorer, it says that there are (No tasks found). My coworker and I looked up solutions that worked for other people, many of which reported having success after restarting VS, clearing some cached data, or reinstalling the node modules; however none of those worked for me. Here are some solutions I've attempted:
Visual Studio 2015 RC Gulp task runner not detecting tasks (All Answers)
https://stackoverflow.com/a/37437209/6425704
Basically the entire first page of Google for "visual studio gulp no tasks found"
The Problem
After some digging, I came across the Package Manager Console and decided that maybe I can run gulp through that instead of opening a separate CMD window. However, when I did, I got the following:
[11:27:43] Local gulp not found in C:\
[11:27:43] Try running: npm install gulp
My immediate thought was that I might need to reinstall the dependencies, so I ran npm install and got this output:
npm : npm WARN enoent ENOENT: no such file or directory, open 'C:\package.json'
At line:1 char:1
+ npm install
+ ~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (npm WARN enoent...:\package.json':String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm
WARN
!invalid#1 No license field.
This is when I noticed that it is looking for C:\package.json instead of the one inside my Project directory. However, when I ran ls, it clearly shows that it's inside the Solution root, at C:\Dev\solution-name. I tried navigating to the specific Project, using cd Presentation\Nop.Web, but I still get the result of it looking in the C:\ root. Can anyone explain why this is happening and how I can fix it?
I finally figured it out (one more day, and I would've offered a bounty for this question), and it's not a problem with VS. Back when I first started using this specific computer and was still using Windows' default Command Prompt, I didn't like it starting in %USERPROFILE% by default. So I looked for a way change the default and stumbled upon a registry "hack" which essentially runs cd C:/ on cmd.exe startup. However, it turns out that this causes other command line tools, including Powershell and VS's Package Manager to run that command.
If anyone else is experiencing this issue (which, due to the nature of this situation, I doubt anyone has), you can try following these steps:
Open up Registry Editor. I did it by using the Windows Run tool (Win + R) and typing regedit.
Navigate to HKEY_CURRENT_USER > SOFTWARE > Microsoft > Command Processor.
Remove AutoRun (or change its value to something that won't interfere with your workflow).
More info here.
Original Registry Tutorial (Note that if I had scrolled down a bit more, I might have avoided this situation.)

Resources