Vince
Vince

Reputation: 101

Firebase Serve Error

I am new to firebase and am trying to make a simple app that utilizes user authentication. At this point in the project I am trying to run firebase on a local server using CLI commands.
I have set up firebase init and firebase deploy. When I type firebase serve on my project folder i get the response,

"an unexpected error has occurred".

Below i am attaching the contents of my firebase-debug.log file. Any help would be appreciated. Thanks

command requires scopes:

["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase",... [debug] [2017-06-11T17:09:09.607Z] > authorizing via signed-in user

TypeError: Cannot read property 'public' of undefined

Upvotes: 9

Views: 9154

Answers (7)

y3gb
y3gb

Reputation: 51

The error comes because we didn't select Firebase features right before hitting Enter button just hit space button to select the feature.

Upvotes: 0

Vlad
Vlad

Reputation: 8552

As for me the error is (--debug attr)

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase-tools/node_modules/@google-cloud/functions-emulator/logs'

So the solution will be to run with sudo

Upvotes: 0

Siddharth Kumar
Siddharth Kumar

Reputation: 1715

I faced this issue today, I ran it with --debug and found out that I've installed npm/node as sudo user, running following:

firebase serve

was giving me this error:

Error: An unexpected error has occurred.

When I ran it with sudo, I was able to deploy hosting and functions locally:

sudo firebase serve --debug --only hosting,functions

Upvotes: 8

Mike Brian Olivera
Mike Brian Olivera

Reputation: 1601

1) create a folder called "public" and put your files inside.

2) edit the firebase.json and just write this:

{ 
 "hosting": {
"public": "public" 
}
}

Upvotes: 3

Ryan
Ryan

Reputation: 1

I think you may have skipped an initialization step by accident (I did the same thing on my first run-through)

Try this (from your same project directory):

1) firebase init

2) When prompted for which services you'll need make sure that Database AND Hosting options have their markers highlighted green (tab to Hosting with the spacebar). It's easy to select just database and let it run its configuration and assume it configures all of the bulleted options below it if you do not watch closely because the stdout info isn't very clear. Now hit Enter

3) Accept the default database settings as you probably did before, and when asked "What do you want to use as your public directory? (public)", hit Enter.

At this point you should be good to go spin up a local firebase web server...

4) try 'firebase serve', hit Enter, and you should get a verification that hosting files are being served from /public

Hope this helps. Good luck.

Upvotes: 0

UKDataGeek
UKDataGeek

Reputation: 6902

This appears to be a bug - that ideally should be resolved with Firebase Init. I have logged a support ticket with Firebase, and would encourage others to do so as well.

Upvotes: 1

davidvgalbraith
davidvgalbraith

Reputation: 461

Look in your firebase.json file, which you should have in the directory where you're running firebase serve. It should look something like this:

{
  "hosting": {
    "public": "app",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

If it doesn't have that "hosting" key, then you'll get that Cannot read property 'public' of undefined error because firebase serve tries to access .hosting.public.

Upvotes: 11

Related Questions