Firebase and Webstorm configuration

Hello, I've started using webstorm, and judging by youtube tutorials it will make coding so much more enjoyable, however i have a problem that i can't pass.

I use firebase in my project, and whenever i'm trying to debugg my javascript file, to see live results of console in webstorm, im getting an error which is: 

firebase.initializeApp(config);
^

ReferenceError: firebase is not defined

 

Now, i've read that i need libraries for it to work, but I do have them installed, and it still doesn't see it. Anyone had similar problems and know the drill? Thanks for help!

1
8 comments
  ReferenceError: firebase is not defined is a runtime error not related to WebStorm, so setting up libraries in WebStorm won't help - the latter are only used by IDE itself for completion. How do you run/debug your code in WebStorm? Does it work when running it outside of WebStorm?
0

I have both my HTML and js files opened in webstorm, then, when js file is active i right click and do debug namefile.js, pretty much just as in the official jetbrain's youtube channel, where someone explains how debugging works

0

Not sure what channel you refer to... Your application is a client-side web application run in browser, the entry point for such app is the HTML file, not .js. Run/Debug actions in js file right-click menu run JavaScript as a console application with Node.js. And Firebase is not defined in this context.

So, to run/debug your application in WebStorm, right-click your HTML file and choose either Run or Debug

0

So basically, I've created sample test.html file and test.js file.

This is what I get and should be getting based on youtube tutorial:


I have a console, where i see my console.log values, i can make breakpoints and run trough my code in debugger tab. Everything works fine, whereas in my primary html+js files where i work on my university project, I use firebase and mentioned above error pops up, making it unable to work on js file, running trough code.

That's how it looks:

Any suggestions, i really would love to have it working..

 

0

Please read my previous comment. In your screenshot I can clearly see that your are running your index.js with Node.js. And you should have run your html file instead

0

I think you're missing my point, when i run HTML file the website loads and it's okay, but i'm losing on debugger functionality with this error. Whether i run html or not, i can't use debugger on .js file, just as i did in first screen(which was supposed to be a demonstration that it should be working like that).

The fact you tell me to run HTML file doesn't fix that error, which is still there.

0

>when i run HTML file the website loads and it's okay, but i'm losing on debugger functionality with this error. 

what error? ReferenceError: firebase is not defined? If it's not defined, how can your website load?

If you like to debug application that runs in browser, choose Debug from HTML right-click menu. see https://www.jetbrains.com/help/webstorm/2017.3/debugging-javascript-in-chrome.html

0

I have just come across this oldish post.

I suppose the OP just ran the html file using preview icons and the built-in WS webserver, typically on port 63342. If this is the case, then he/she was likely to run into the problem of additional URL slug after the localhost part. Given that firebase can use its "hosting reserved URLs" (`/__/firebase...`) the scripts won't load and firebase will be undefined. Although having a built-in web server is handy, its URLs might often make some examples unplayable.  

    

0

Please sign in to leave a comment.