frozeman / meteor-build-client

A tool to bundle the client part of a Meteor app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Loading failed for the <script> with source “file:///....js”.

jankapunkt opened this issue · comments

Just built this with Meteor 1.8.1 and a very simple standard repo (use meteor create) then built this using the manual form the README.

Build was fast and without errors and created a folder with the following files:

  • index.html
  • 524ea151167f0aa67862fb6b681b532466a7bc87.css
  • c1e4e82dccf23c3809384659c50aa0177fedfcbe.js
  • c1e4e82dccf23c3809384659c50aa0177fedfcbe.stats.json

However opening the index.html file locally caused the following error:

Loading failed for the <script> with source “file:///c1e4e82dccf23c3809384659c50aa0177fedfcbe.js”.
ReferenceError: Meteor is not defined

Edit: the above error occurred on FireFox, while Chrome gave me this output:

Failed to load resource: net::ERR_FILE_NOT_FOUND (c1e4e82dccf23c3809384659c50aa0177fedfcbe.js:1)
Failed to load resource: net::ERR_FILE_NOT_FOUND (/524ea151167f0aa67862fb6b681b532466a7bc87.css?meteor_css_resource=true:1)
Uncaught ReferenceError: Meteor is not defined
    at index.html:7 (index.html:7)

Note, that the error also occurs when using within github pages. I tried to change the -p options without success.

Okay found the cause. First the paths should not include /, which is achieved using the -p "" option. However, it still won't load because the __meteor_runtime_config__ is missing the property autoupdate (which itself has to have the property versions) and I can't find it in the code.

My (manually applied) hotfix is to change the __meteor_runtime_config__ code int the index.html from

<script type="text/javascript">__meteor_runtime_config__ = JSON.parse(decodeURIComponent("..."));</script>

to

<script type="text/javascript">__meteor_runtime_config__ = Object.assign({autoupdate:{versions:{}}}, JSON.parse(decodeURIComponent("...")));</script>

Which is not a real fix but makes it run. Can anyone explain what happened here? I'd provide a fix / PR but I have no clue why this autoupdate property is needed.

Hello @jankapunkt ,

Thank you for pointing this out :)
Fixed as part of v1.0.0, and published last night to NPM. Please, give it a try and let me know if there's any issues.