elm-community/elm-webpack-loader

Error While using elm-webpack-loader inside docker

blisscs opened this issue · 3 comments

Hi,
When I try to use elm-webpack-loader inside docker, I am getting error as below when running webpack in development mode.

/node_modules/node-elm-compiler/dist/index.js:85 phoenix_webauthn_sample_1 | .on('error', function (err) { throw (err); });

But when run in production mode it's working fine.
And when I run it without docker it's working fine.

To see my code folder and docker setup please checkout this code https://github.com/blisscs/phoenix-webauthn-sample/tree/setup-phoenix-elm . It's a phoenix app that uses webpack with elm for frontend.

To try the setup use following command to see errors-

docker-compose build
docker-compose run phoenix_webauthn_sample mix ecto.setup
docker-compose run phoenix_webauthn_sample cd assets && yarn install
docker-compose up

Best
Dev.

After further try out to resolve this issue I found another issue as I was trying things inside docker container as below -

When I run command
$ yarn run webpack --mode development I could build assets for elm
but when I use
$ assets/node_modules/.bin/webpack --mode development I could not build assets.
And I got following errors as below -

/phoenix-webauthn-sample/assets/node_modules/elm-webpack-loader/node_modules/node-elm-compiler/dist/index.js:85
.on('error', function (err) { throw (err); });
^

Error: spawn elm ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:19)
at onErrorNT (internal/child_process.js:430:16)
at processTicksAndRejections (internal/process/next_tick.js:76:17)

I had the same issue. Managed to resolve it by adding pathToElm: “node_modules/.bin/elm” to the elm-webpack-loader options in webpack config.

Thank you @mnemoli

Use pathToElm option resolve the issue.