简体   繁体   English

'firebase' 不是内部或外部命令,也不是可运行的程序或批处理文件

[英]'firebase' is not recognized as an internal or external command, operable program or batch file

I am in a bizarre problem, I just updated my Node.js and NPM at the date of 01-Feb-2019.我遇到了一个奇怪的问题,我刚刚在 2019 年 2 月 1 日更新了我的 Node.js 和 NPM。 And used the following command-并使用了以下命令-

npm install -g firebase-tools

to install the Firebase CLI安装 Firebase CLI

Then on typing either of the code below然后输入以下任一代码

firebase login

or或者

firebase init

it is showing the following error它显示以下错误

'firebase' is not recognized as an internal or external command, operable program or batch file. 'firebase' 不是内部或外部命令,也不是可运行的程序或批处理文件。

Please help me.请帮我。 It has already consumed my two days.它已经消耗了我两天的时间。

Ok.好的。 First of all, Bizarre problem has some bizarre solution.首先,奇怪的问题有一些奇怪的解决方案。 Uninstall your node js and NPM completely.完全卸载你的 node js 和 NPM。 Then reinstall it, and check, whether it works or not.然后重新安装它,并检查它是否有效。 Best of Luck祝你好运

npm install -g firebase-tools -f npm install -g firebase-tools -f

Using -f for force install again.再次使用 -f 强制安装。 This work for me这对我有用

add to .bash_profile export PATH="$PATH:/usr/local/bin" and run添加到 .bash_profile export PATH="$PATH:/usr/local/bin"并运行

npm install -g firebase-tools

this worked for me这对我有用

Navigate to the firebase directory and call it out on the cmd.导航到 firebase 目录并在 cmd 上调用它。

  • run cmd as admin以管理员身份运行cmd
  • cd C:\\users\\yourusername\\AppData\\Roaming\\npm cd C:\\users\\您的用户名\\AppData\\Roaming\\npm
  • firebase.cmd login or firebase login firebase.cmd 登录或 firebase 登录
  • firebase will prompt a google login after which the issue should be resolved. firebase 将提示谷歌登录,然后问题应该得到解决。

There you go.你去吧。 above steps are all commands goes to your command prompt.以上步骤是所有命令都转到您的命令提示符。

确保您以管理员身份运行命令行。

If you are using MS Windows:如果您使用的是 MS Windows:

  1. Open Start Menu or press Win button on your keyboard.打开开始菜单或按键盘上的 Win 按钮。
  2. Type "variables".输入“变量”。
  3. Click on "Edit the system environment variables"点击“编辑系统环境变量”
  4. Click on "Environment Variables..." button.单击“环境变量...”按钮。
  5. In the "System variables" list select "Path" and click on the "Edit..." button under the list.在“系统变量”列表中选择“路径”并单击列表下的“编辑...”按钮。
  6. In the "Edit environment variable" dialog click on the "Browse..." button.在“编辑环境变量”对话框中单击“浏览...”按钮。
  7. Navigate to the "c:\\users<yourusername>\\AppData\\Roaming" dir and select the "npm" sub-dir, then click "OK".导航到“c:\\users<yourusername>\\AppData\\Roaming”目录并选择“npm”子目录,然后单击“确定”。
  8. In the "Edit environment variable" dialog click "OK".在“编辑环境变量”对话框中单击“确定”。
  9. In the "Environment Variables" dialog click on "OK".在“环境变量”对话框中单击“确定”。

For the Linux users:对于 Linux 用户:

  1. Navigate to the home_dir.导航到 home_dir。
  2. Edit the hidden ".bash_profile" file.编辑隐藏的“.bash_profile”文件。
  3. Add line with following text "export PATH="$PATH:/usr/local/bin".添加带有以下文本“export PATH="$PATH:/usr/local/bin”的行。

After installing安装后

$ npm install -g firebase-tools

Note the directory where it installed What I did was locate the directory where firebase was installed.注意它安装的目录我所做的是找到安装 firebase 的目录。 In my case C:\\usr\\local then I copied the three firebase files.在我的情况下C:\\usr\\local然后我复制了三个 firebase 文件。 I also went into the node_modules folder and copied the firebase tools folder.我还进入了node_modules文件夹并复制了node_modules工具文件夹。 Then I went to my app directory in file manager and pasted the firebase files, then created a new node_modules folder and pasted the firebase-tools folder.然后我转到文件管理器中的应用程序目录并粘贴node_modules文件,然后创建一个新的node_modules文件夹并粘贴node_modules -tools 文件夹。

Now go to your cmd and run现在转到您的 cmd 并运行

$ firebase init

It should work它应该工作

After running npm install -g firebase-tools , go to C:\\usr\\local .运行npm install -g firebase-tools ,转到C:\\usr\\local You will see Firebase files.您将看到 Firebase 文件。

  1. Copy this path C:\\usr\\local to the clipboard.将此路径C:\\usr\\local复制到剪贴板。
  2. Open the Start Menu and search for Edit the System Environment Variables or simply env .打开开始菜单并搜索Edit the System Environment Variables或简单地env
  3. Select the environment variables option that appears.选择出现的环境变量选项。
  4. Find the PATH variable under the system environment variables (lower section).在系统环境变量(下半部分)下找到PATH变量。
  5. Select PATH and click Edit选择PATH并点击编辑
  6. Add C:\\user\\local to the beginning of the path.C:\\user\\local添加到路径的开头。
  7. Add %APPDATA%\\npm if it doesn't exist.如果不存在,请添加%APPDATA%\\npm
  8. Click OK to each of the windows until they're all closed.对每个窗口单击“确定”,直到它们全部关闭。

After this, open a Windows command prompt and run firebase --version .之后,打开 Windows 命令提示符并运行firebase --version

Make sure you run the CMD in administrator mode.确保在管理员模式下运行 CMD。 Also once you have run npm install -g firebase-tools commands close the CMD prompt and reopen again.此外,一旦您运行 npm install -g firebase-tools 命令,请关闭 CMD 提示符并再次重新打开。 If this doesn't work uninstall node and reinstall it again.如果这不起作用,请卸载节点并重新安装。 It requires your node version to be a minimum version to support firebase.它要求您的节点版本是支持 firebase 的最低版本。

For peeps like me who were unable to get rid of this problem after trying everything suggested above.对于像我这样在尝试了上面建议的所有方法后无法摆脱这个问题的窥视者。 I know it is late but I Fixed it by changing the location for installing my packages.我知道已经晚了,但我通过更改安装包的位置来修复它。 I ran the command "npm config get prefix" in cmd and I found out that my default location for node_modules installation had been changed.我在 cmd 中运行命令“npm config get prefix”,我发现 node_modules 安装的默认位置已更改。 so I set it back to default by "npm config set prefix "C:\\Users\\your_PC_Name\\AppData\\Roaming\\npm". After that I used "npm install -g firebase-tools" again所以我通过“npm config set prefix "C:\\Users\\your_PC_Name\\AppData\\Roaming\\npm”将它设置回默认值。之后我再次使用了“npm install -g firebase-tools”

My firebase package was installed.我的 firebase 软件包已安装。 I was relieved to see firebase.cmd file in npm folder.看到 npm 文件夹中的 firebase.cmd 文件,我松了一口气。 Earlier I had tried every thing like uninstalling node.js and deleting npm and npm cache folders but all those methods didn't work for me.早些时候,我尝试了卸载 node.js 和删除 npm 和 npm 缓存文件夹等所有方法,但所有这些方法对我都不起作用。

Cannot get "npm install -g" to work on any packages (AppData/Roaming/npm always empty) this discussion worked for me only. 无法让“npm install -g”处理任何包(AppData/Roaming/npm 总是空的)这个讨论只对我有用

所有简单快捷的解决方案都在这里...... step1):只需转到 C:\\Users\\your-user-name\\AppData\\Roaming\\npm step2):复制此“npm”文件夹的路径 step3):现在转到开始并输入“env”并选择第一个选项然后步骤4):现在通过单击“编辑”按钮将该路径粘贴到“路径”选项中步骤5):然后单击“确定”并重新启动您的电脑

I had similar issue in MAC.我在 MAC 中遇到了类似的问题。 Terminal was giving me command not found message on running "firebase --version".终端在运行“firebase --version”时给了我未找到命令的消息 So, I tried to reinstall the firebase with the command: "sudo npm ig firebase-tools" but it again errored out stating that the installed firebase binary file is corrupted.因此,我尝试使用以下命令重新安装 firebase:“sudo npm ig firebase-tools”,但它再次出错,指出已安装的 firebase 二进制文件已损坏。

Solution : STEP 1. Provide read, write and execute access with "sudo chmod a+rwx configstore" cmd to the path :解决方案:步骤 1. 使用“sudo chmod a+rwx configstore”cmd 提供对路径的读、写和执行访问:

"/Users//.config/configstore/" "/Users//.config/configstore/"

STEP 2. Run following command to update firebase:步骤 2. 运行以下命令来更新 Firebase:

sudo curl -sL firebase.tools | sudo curl -sL firebase.tools | upgrade=true bash升级=真重击

C:\\users\\yourusername\\AppData\\Roaming\\npm到环境变量 PATH。

对于仍在与此问题作斗争的任何人,请尝试将系统环境路径添加到用户环境中。

https://github.com/firebase/firebase-tools/issues/46#issuecomment-615534999 https://github.com/firebase/firebase-tools/issues/46#issuecomment-615534999

  1. Run your cmd from C:\\Windows\\System32\\cmd.exe or type this in your file path and hit EnterC:\\Windows\\System32\\cmd.exe运行你的 cmd 或在你的文件路径中输入它并按 Enter
  2. Just reinstall firebas-tools {npm i firebase-tools -g} globally只需在全局重新安装 firebas-tools {npm i firebase- tools -g}
  3. Restart your computer its work for me good luck重启你的电脑,祝我好运

Simple answer to this question is-这个问题的简单答案是——
1. npm install firebase command in terminal window. 1. 在终端窗口中npm install firebase命令。
2.Add firebase scripts in your editor that you use. 2.在您使用的编辑器中添加firebase 脚本
3. set the Path in the environment system variable. 3.在环境系统变量中设置Path

I think it will be able solve your problem...我认为它可以解决您的问题......

1.After installing firebase globally via npm i -g firebase-tools 1.通过npm i -g firebase-tools全局安装 firebase 后

2.simply run all your firebase commands from the node command-line tool, it instantly worked for me. 2. 只需从 node 命令行工具运行所有 firebase 命令,它立即对我有用。

3.To access the node command line, simply go to the start menu on windows and type "node.js command prompt" 3.要访问节点命令行,只需转到Windows上的开始菜单并键入“node.js command prompt”

My solution is to use Firebase CLI binary for Windows:我的解决方案是对 Windows 使用 Firebase CLI 二进制文件:

  1. Download CLI: https://firebase.google.com/docs/cli#install-cli-windows下载 CLI: https : //firebase.google.com/docs/cli#install-cli-windows
  2. Run CLI, go to the project directory (cd 'your app path').运行 CLI,转到项目目录(cd 'your app path')。 By the way, you may see the version: run "firebase --version" for that顺便说一句,您可能会看到版本:为此运行“firebase --version”
  3. Run "firebase login" with Firebase CLI使用 Firebase CLI 运行“firebase login”
  4. Run "firebase init" with Firebase CLI使用 Firebase CLI 运行“firebase init”

Add this to the environment variable:-将此添加到环境变量中:-

C:\Users\<user>\AppData\Roaming\npm\firebase

it will allow firebase commands in ps/cmd它将允许 ps/cmd 中的 firebase 命令

i dont think : C:\\Users<user>\\AppData\\Roaming\\npm\\ now works.我不认为: C:\\Users<user>\\AppData\\Roaming\\npm\\ 现在可以工作了。

My solution was that my project was on partition F: somedirectory/app ,and when I moved it on partition C: Users/username/Documents/app It worked!我的解决方案是我的项目在分区 F: somedirectory/app 上,当我将它移动到分区 C: Users/username/Documents/app 时,它起作用了! I tried everything mentioned and more, lost couple of hours.我尝试了提到的所有内容以及更多内容,但损失了几个小时。 So moving on partition where I installed: npm install -g firebase-tools then: firebase login , then: firebase init所以继续我安装的分区: npm install -g firebase-tools 然后: firebase login ,然后: firebase init

npx firebase <your command>

If you have similar problems like this如果你有类似这样的问题

firebase : File C:\Users\<user-name>\AppData\Roaming\npm\firebase.ps1 cannot be loaded because running scripts is disabled on this system. For more em. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ firebase login
+ ~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

perhaps you can try to Ctrl + Click the C:\Users<user-name>\AppData\Roaming\npm\firebase.ps1也许你可以尝试Ctrl + 单击C:\Users<user-name>\AppData\Roaming\npm\firebase.ps1

After that you'll see a new PowerShell Terminal and you can continue it.之后你会看到一个新的 PowerShell 终端,你可以继续它。

Hope it's works希望它的作品

I was struggling with this same issue for a few days and had an issue where my NPM was installed in two different places for whatever reason.我在同一个问题上苦苦挣扎了几天,并且遇到了一个问题,即我的 NPM 出于某种原因被安装在两个不同的地方。

I had an npm folder in C:\Users\<user>\AppData\Roaming\npm\ as well as C:\Users\<user>\npm\我在C:\Users\<user>\AppData\Roaming\npm\C:\Users\<user>\npm\中有一个 npm 文件夹

Turns out the Firebase installation command installed all the needed files into the latter folder, while my Environment PATH was pointing to the first folder.原来 Firebase 安装命令将所有需要的文件安装到后一个文件夹中,而我的环境路径指向第一个文件夹。

I changed my PATH variable to C:\Users\<user>\npm\ and ran the firebase installation again.我将 PATH 变量更改为C:\Users\<user>\npm\并再次运行 firebase 安装。 After that everything started working fine.之后一切都开始正常工作。

If you havent checked the other answers about what PATH is, you can access it by typing env in the Windows search bar and from there click the Environment Variables button.如果您还没有检查过关于 PATH 是什么的其他答案,您可以通过在 Windows 搜索栏中键入env来访问它,然后从那里单击Environment Variables按钮。 Then double click the Path line under System variables to edit it.然后双击系统变量下的Path行进行编辑。 Remember to press OK to save any changes.请记住按确定以保存任何更改。

This is probably a rare edgecase, but maybe it will help someone.这可能是一个罕见的边缘案例,但也许它会对某人有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SendGrid: 'source' 不是内部或外部命令,也不是可运行的程序或批处理文件 - SendGrid: 'source' is not recognized as an internal or external command, operable program or batch file firebase 部署错误:'eslint 未被识别为内部或外部命令、可运行程序或批处理文件' - firebase deploy error: 'eslint is not recognized as an internal or external command, operable program or batch file' 尝试构建 jar 文件时,“gradle”未被识别为内部或外部命令 - 'gradle' is not recognized as an internal or external command when trying to build jar file 术语“flutterfire”未被识别为 cmdlet、function、脚本文件或可运行程序的名称 - The term 'flutterfire' is not recognized as the name of a cmdlet, function, script file, or operable program 术语“googet”未被识别为 cmdlet、function、脚本文件或可运行程序的名称 - The term 'googet' is not recognized as the name of a cmdlet, function, script file, or operable program azure 应用服务(“bf”未被识别为内部或外部命令) - azure app service ('bf' is not recognized as an internal or external command) 'Get-ECRLoginCommand' 未被识别为 cmdlet、function、脚本文件或可运行程序的名称 - 'Get-ECRLoginCommand' is not recognized as the name of a cmdlet, function, script file, or operable program flutterfire:术语“flutterfire”未被识别为 cmdlet、function、脚本文件或可运行程序的名称 - flutterfire : The term 'flutterfire' is not recognized as the name of a cmdlet, function, script file, or operable program 在 cmd 中运行 aws 命令时,'more' 未被识别为内部命令错误 - 'more' is not recognized as an internal command error when aws command is run in cmd Firebase 分析 function 未被识别 - Firebase Analytics function not being recognized
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM