question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firebase serve not working with module import (polymer 3)

See original GitHub issue

I’m trying to create a polymer 3 app and have it hosted using firebase hosting, and for my dev im using firebase tool in order to try test thing up locally before production. When i try to serve my app using firebase serve command everything is appearing to work okay:

  • Serving from '/Users/Terence/Desktop/BaseScholar'...

- i hosting: Serving hosting files from: public

- ✔ hosting: Local server: http://localhost:5000

When I open the browser nothing is showing, and in my console im getting this error:

Uncaught TypeError: Failed to resolve module specifier "@polymer/polymer/polymer-element.js". Relative references must start with either "/", "./", or "../".

Part of the code in my index.hmtl file:

<html lang="en">
<head>
  <title>BaseScholar</title>

  <script src="https://www.gstatic.com/firebasejs/5.0.4/firebase.js"></script>
  <script>
    // initialize firebase app
    var config = {
      apiKey: "<API_KEY>",
      authDomain: "<PROJECT_ID>.firebaseapp.com",
      databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
      projectId: "<PROJECT_ID>",
      storageBucket: "<BUCKET>.appspot.com",
      messagingSenderId: "<SENDER_ID>"
    };
    firebase.initializeApp(config);
  </script>

  <!-- Load webcomponents-loader.js to check and load any polyfills your browser needs -->
  <script src="node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
  <script src="node_modules/web-animations-js/web-animations-next-lite.min.js"></script>

  <script type="module" src="src/elements/basescholar-app.js"></script>
  <!-- Add any global styles for body, document, etc. -->
  <style>
    body {
      margin: 0;
      padding: 0;
    }
  </style>
</head>

<body unresolved>

  <!-- Instantiate the BaseScholar app: -->
  <basescholar-app></basescholar-app>
  <noscript>
    Please enable Javascript in order access the application
  </noscript>
</body>
</html>

I’m building and running the app on MacOS High Sierra. Browser (Google Chrome v67).

How can I resolve this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
stackt52commented, Jun 5, 2018

So I built the app as @CaptainCodeman advised and got rid of the **/node_modules/* according to @yanchespenda and everything starts working perfectly fine now - I can now deploy my app to firebase, problem solved!!. Thanks very much guys

0reactions
JeanRemiDelteilcommented, Jul 16, 2018

@mbleigh I understand that the server is not opinionated about stacks. However, the ground issue here is simply the use of NPM packages in front-end dev environnements. And this is not just limited to one specific stack. We should be able to specify import resolution to use NodeJs resolution

My approach for now is to take a look at how firebase serve and superstatic are working. As of now it seems to me that it does not provide as much middleware insertion point as I wanted (but it may need more investigation with the express + superstatics as middleware approach).

The big pain point is that my whole app is built on Firebase + Polymer tech, and taking advantage of the new releases is not really possible without the hot reloading we currently enjoy with firebase serve. Well, maybe that meant I was relying too much upon once tool…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firebase Cloud Functions and Nuxt3: Cannot use import ...
I ran into issues like this trying to organize my functions as well. I had to user require to get this to work...
Read more >
firebase app named '[default]' already exists with different ...
Sometimes, when you import the firebase.js file in multiple other files, it may try to create two instances of the app. To prevent...
Read more >
Build for production - Polymer Project
polymer serve does this. According to the native Custom Elements V1 spec, elements must be defined using ES6 classes. ES5-defined elements will error...
Read more >
@polymer/app-storage - npm
App-Storage. These are a set of behaviors and elements that make it easy to synchronize in-memory data to persistant storage systems.
Read more >
Polymer vs Angular: Which is leading the future of web apps?
“Three cutting-edge new features of the web platform—Web Components, HTTP/2 + Server Push, and Service Worker—all work seamlessly together to provide a totally ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found