使用 "firebase init" 在本地开始一个新项目会得到 "Server Error. certificate has expired"

Starting a new project locally with "firebase init" gives "Server Error. certificate has expired"

我正在尝试在 Mac OS 的新文件夹中设置一个全新的项目,作者是 运行:

firebase init

而且我总是得到同样的错误:

Error: Server Error. certificate has expired

我尝试了 中提到的不同方法,例如:

npm i -g firebase-tools@latest
sudo npm i -g firebase-tools@latest
npm install --save firebase

没有任何帮助。下面分享firebase-debug.log

[debug] [2020-02-02T21:27:36.490Z] ----------------------------------------------------------------------
[debug] [2020-02-02T21:27:36.493Z] Command:       /usr/local/bin/node /usr/local/bin/firebase init hosting
[debug] [2020-02-02T21:27:36.493Z] CLI Version:   3.18.5
[debug] [2020-02-02T21:27:36.493Z] Platform:      darwin
[debug] [2020-02-02T21:27:36.493Z] Node Version:  v10.16.0
[debug] [2020-02-02T21:27:36.500Z] Time:          Sun Feb 02 2020 22:27:36 GMT+0100 (Central European Standard Time)
[debug] [2020-02-02T21:27:36.500Z] ----------------------------------------------------------------------
[debug] 
[debug] [2020-02-02T21:27:36.511Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"]
[debug] [2020-02-02T21:27:36.512Z] > authorizing via signed-in user
[info] 
                      
                                               
                      
                                               
                               

You're about to initialize a Firebase project in this directory:

  /Users/user/apps/laisvi

[info] 
=== Project Setup
[info] 
[info] First, let's associate this project directory with a Firebase project.
[info] You can create multiple project aliases by running firebase use --add, 
[info] but for now we'll just set up a default project.
[info] 
[debug] [2020-02-02T21:27:36.519Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects  

 Sun Feb 02 2020 22:27:36 GMT+0100 (Central European Standard Time)
[debug] [2020-02-02T21:27:37.059Z] Error: certificate has expired
    at TLSSocket.onConnectSecure (_tls_wrap.js:1055:34)
    at TLSSocket.emit (events.js:198:13)
    at TLSSocket.EventEmitter.emit (domain.js:448:20)
    at TLSSocket._finishInit (_tls_wrap.js:633:8)
[error] 
[error] Error: Server Error. certificate has expired

我认为这是一个不同的问题,可能与 Linux 上的权利有关?有人面临同样的问题吗?

找到解决方案!

问题是我使用旧文档安装了 firebase,它链接到 firebase 命令而忽略了默认情况下没有任何别名的 firebase-tools。我的步数:

第 1 步: 找到 firebase:

which firebase

第 2 步:删除 firebase

rm // whatever location it gave you which firebase

第 3 步:再次安装 firebase-tools(可能不需要)

npm i -g firebase-tools@latest

步骤 4:为工具创建别名

alias firebase="`npm config get prefix`/bin/firebase"

您现在可以 firebase init 并最终使用 vanilla Js 创建一个 firebase 项目!