Phoenix Liveview Helpers folder not functioning properly

After I use mix.gen.live to generate a liveview setup, I’m met with an error:

== Compilation error in file lib/twitterclone_web/live/live_helpers.ex ==
** (CompileError) lib/twitterclone_web/live/live_helpers.ex:57: Phoenix.LiveView.JS.struct/1 is undefined, cannot expand struct Phoenix.LiveView.JS. Make sure the struct name is correct. If the struct name exists and is correct but it still cannot be found, you likely have cyclic module
usage in your code
lib/twitterclone_web/live/live_helpers.ex:57: (module)

I found a related issue: https://github.com/phoenixframework/phoenix/issues/4642 that points to phoenix liveview 0.17+ not being loaded. How do I go about updating my version of Liveview within my mix.exs file?

Thank you.

Hi, just change the line

{:phoenix_live_view, "~> X.X"}

in you deps to

{:phoenix_live_view, "~> 0.17"}

and run mix deps.get.

1 Like

I did that and then ran into other dependency issues:

Failed to use “phoenix_live_view” (version 0.17.6) because
phoenix_live_dashboard (version 0.5.3) requires ~> 0.16.0
mix.lock specifies 0.17.6

Then you also need to update your phoenix_live_dashboard dependency.

Just change it to

{:phoenix_live_dashboard, "~> 0.6"}

Ah, of course. Thank you.

This might be an overreach, but my IED is still displaying an exception within my mix file, by underlining all the code red. If I type in the older dependencies, the code exceptions disappear. This obviously isn’t the proper way to go about fixing the issue. Any suggestions?

Is that VSCode by any change with elixir_ls package? If so, try rm -rf .elixir_ls _build and then compile your project again. Also reboot the editor.

1 Like