Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elm-watch succeeds in compiling, but in browser shows "Uncaught ReferenceError: _Platform_enqueueEffects is not defined" error and fails to start / validate elm/core version is recent enough #101

Open
casperschipper opened this issue Aug 26, 2024 · 4 comments

Comments

@casperschipper
Copy link

casperschipper commented Aug 26, 2024

One of my Elm apps shows the following error in the browser console when I try to use elm-watch:

Uncaught ReferenceError: _Platform_enqueueEffects is not defined _Platform_initialize http://127.0.0.1:8080/elm.js:4788 _Browser_element http://127.0.0.1:8080/elm.js:6978 F4 http://127.0.0.1:8080/elm.js:2892 init http://127.0.0.1:8080/elm.js:5364 <anonymous> http://127.0.0.1:8080/:22

The widget shows ❓ and reports "It looks like no Elm apps were initialized by elm-watch. Check the console in the browser developer tools to see potential errors!"

Elm-watch.json is as follows:
{ "targets": { "My target name": { "inputs": [ "src/Main.elm" ], "output": "elm.js" } } }

Elm-watch itself reports a success compilation, however the browser shows the above error. I have tried a "clean slate" by removing the complete elm-watch folder and even elm-stuff, but the error keeps happening. As far as I can see, I haven't done anything unusual, it is a very simple Browser.element app. Building the app with elm-watch make works fine.
My other apps also run on elm-watch without problems. So I am somewhat mystified.

Anyhow, thank you for making elm-watch, it has been very useful despite this error.

@lydell
Copy link
Owner

lydell commented Aug 26, 2024

Hi! Can you create a repo that reproduces this problem, that I can clone and debug?

@casperschipper
Copy link
Author

Of course, I think I managed to make a minimum example:
https://github.com/casperschipper/elm-watch-issue-101/tree/main

@lydell
Copy link
Owner

lydell commented Aug 26, 2024

Awesome, thank you!

I turns out the error was because your elm/core version is too old. If you change your elm.json like this it starts working:

         "direct": {
             "billstclair/elm-sortable-table": "1.2.0",
             "elm/browser": "1.0.1",
-            "elm/core": "1.0.2",
+            "elm/core": "1.0.5",
             "elm/html": "1.0.0",
             "elm/http": "2.0.0",
             "elm/json": "1.1.3",

There is a (pretty hidden and vague) note about this at https://lydell.github.io/elm-watch/hot-reloading/:

You need a recent enough elm/core version. Otherwise some regexes don’t match. Perfect time to update, though!

elm-watch already parses elm.json, so while doing that I could also validate that you have a recent enough version of elm/core and give a specific error message if this happens. I’m keeping the issue open for that!

@lydell lydell changed the title Elm-watch succeeds in compiling, but in browser shows "Uncaught ReferenceError: _Platform_enqueueEffects is not defined" error and fails to start Elm-watch succeeds in compiling, but in browser shows "Uncaught ReferenceError: _Platform_enqueueEffects is not defined" error and fails to start / validate elm/core version is recent enough Aug 26, 2024
@casperschipper
Copy link
Author

casperschipper commented Aug 27, 2024

Amazing, and indeed, problem solved!

@github-staff github-staff deleted a comment from Lxx-c Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants