tools: Element template has bad paths in demo

After polymer init and polymer serveproject in CLI,

"Uncaught SyntaxError: Unexpected token < " in first line of index.html

Recommended fix: Add type="javascript" under webcomponents-lite.js script tags for resolving the issue

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Comments: 19 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@almielczarek I just realized that you are talking about the element template. Right now we don’t support the application workflow with reusable elements. That means two things:

  1. You can’t build a reusable element - elements should be built in the context of an app, because we can’t know that some dependency that would be bundled with the element isn’t also used somewhere else, and we can’t have more than one copy of a element/library in an app.
  2. Element projects have to be served from a different URL than application projects because element projects use URLs that reach out of the project folder. That’s why polymer serve prints this message:
Files in this directory are available under the following URLs
    applications: http://localhost:8080
    reusable components: http://localhost:8080/components/p1-element/

For elements, you need the second URL.

@SayChunKim I still haven’t been able to reproduce this issue with the application template.

on polymer serve i am getting the link below http://127.0.0.1:8080 but i want the url as http://localhost:8080 how can i change it?

I have encountered the same issue but I found a different fix. The version of polymer-cli I am using is 0.11.1 and I am on Windows 7.

The “element” template has some issues with the relative links on the imports. If you initialize the template then serve it and go to the demo page in your browser then check the network tab the developer tools in chrome it will show that instead of the webcomponents-lite.js file it is loading your html template file.

If you change the beginning of the hrefs to read “…/bower_components/” instead of “…/…/” then everything loads correctly. I don’t believe it has anything to do with the type property being “text/javascript” it seems as if the relative path specified does not exist so it is just loading the index.html file of the project root.

Which template are you initializing from? Can you include steps to reproduce from scratch?