Open DoctorRyner opened 4 years ago
Could you share the command that you ran and a link to the repo so I can test this?
I think I found what could be the cause of this issue, as well as some others that are still open (#205, #195).
I was getting the same error, running this command:
elm-live src/Main.elm --hot --port=3000 --dir=public -- --output=public/app.js
After I added an index.html
file to public/
, the error went away.
It seems elm-live
expects an index.html
file to exist in the directory specified with --dir
, if it's missing, it crashes with this error.
@mapmarkus I just wanted to thank you for sharing what you learned. I ran into this exact issue and all I had to do was remove the --start-page=public/index.html
option (which was pointing to my custom index.html) to match your solution and now it works like a charm.
I not sure how we could clarify how this behavior in the docs, but seems like this it might be a common source of frustration.
Looks like I had to do the same thing. The --dir
option works, but the --start-page
option does not. I had it set to "www/webapp.html" because I didn't want an accidental elm build without parameters to overwrite my html file (since it defaults to index.html as well) so I renamed it webapp.html.
Had to revert back to index.html and remove the start-page option to get it to not crash on certain queries. But it only happens when using --ssl
mode.
I think there's a couple different issues here. When using --output=app.js
you don't automatically get an index.html
and so you have to provide your own. That itself isn't a bug but how the Elm compiler works.
Separately there's an issue with --dir
and --start-page
conflicting with each other. --start-page
is, I think, automatically scoped to --dir
which prevents from running with the options --dir=public --start-page=src/index.html
as now elm-live is looking for the start page at public/src/index.html
.
If you were referring to me, I know that's how the --output works which is why I didn't want my index.html overwritten if I ever were to forget that parameter when building.
But the second thing you mentioned may be an issue, but not one that would crash with the message this thread is about. The "not found" error is different and slightly less cryptic.
The error I get when I use the options --dir=public --start-page=src/index.html
is
internal/fs/utils.js:581
throw new ERR_INVALID_ARG_TYPE(propName, ['string', 'Buffer', 'URL'], path);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
at readFile (fs.js:317:10)
at /usr/local/lib/node_modules/elm-live/node_modules/crocks/Async/index.js:54:10
at Object.fork (/usr/local/lib/node_modules/elm-live/node_modules/crocks/Async/index.js:155:20)
at /usr/local/lib/node_modules/elm-live/node_modules/crocks/Async/index.js:254:41
at settle (/usr/local/lib/node_modules/elm-live/node_modules/crocks/Async/index.js:151:16)
at ReadFileContext.callback (/usr/local/lib/node_modules/elm-live/node_modules/crocks/Async/index.js:56:47)
at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:261:13) {
code: 'ERR_INVALID_ARG_TYPE'
which is the same error as the first message in this thread.
Hello from 2022. In fact --dir option works fine. The problem is error description, which is absolutely useless. When you use --dir with --start-page together, you should use --start-page path relative to --dir path, not the current one. I hope you'll fine a couple of minutes to write another catch statement with proper error description.
I think there's a couple different issues here. When using
--output=app.js
you don't automatically get anindex.html
and so you have to provide your own. That itself isn't a bug but how the Elm compiler works.Separately there's an issue with
--dir
and--start-page
conflicting with each other.--start-page
is, I think, automatically scoped to--dir
which prevents from running with the options--dir=public --start-page=src/index.html
as now elm-live is looking for the start page atpublic/src/index.html
.
@wolfadex this was incredibly helpful!
If the docs could be updated to clarify that --start-page
is scoped to --dir
automatically, that would be great.