Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Trouble building on Windows #1

Closed
j-maas opened this issue Mar 19, 2022 · 8 comments
Closed

Trouble building on Windows #1

j-maas opened this issue Mar 19, 2022 · 8 comments

Comments

@j-maas
Copy link

j-maas commented Mar 19, 2022

I was trying out this repo and ran into some issues that I don't know how to solve. It was a bit bumpy to get started, so I'll just describe what happened, even though not all of it is strictly relevant to the problem.

  1. I cloned the repo as instructed in the README.md.

  2. I ran npm install.

  3. I ran npm run start, but it errored saying it couldn't find lamdera.

  4. I had heard about lamdera roughly so I googled it and simply installed the binary that was available from their website and added it to my PATH.

  5. After reloading the console, I ran npm run start again. It errored because some dependencies were not satisfied.1

  6. I ran lamdera reset.

  7. I ran npm run start, and the dependency error was about a different package.

  8. I ran lamdera reset and npm install.

  9. I ran npm run start and it worked.

  10. I ran npm run build and I get this error message:

    $ npm run build
    
    > build
    > elm-pages build
    
    No `elm-pages.config.mjs` file found. Using default config.
    vite v2.8.6 building for production...
    <script src="/elm.js"> in "/elm-stuff/elm-pages/index.html" can't be bundled without type="module" attribute
    ✓ 5 modules transformed.
    rendering chunks (1)...[vite:build-html] The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "../../../../../C:\Users\Johannes\Code\elm-pages-3-alpha-starter\elm-stuff\elm-pages\index.html".
    Error: The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "../../../../../C:\Users\Johannes\Code\elm-pages-3-alpha-starter\elm-stuff\elm-pages\index.html".
        at error (C:\Users\Johannes\Code\elm-pages-3-alpha-starter\node_modules\rollup\dist\shared\rollup.js:198:30)
        at FileEmitter.emitFile (C:\Users\Johannes\Code\elm-pages-3-alpha-starter\node_modules\rollup\dist\shared\rollup.js:15513:24)
        at Object.generateBundle (C:\Users\Johannes\Code\elm-pages-3-alpha-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:21691:22)
        at processTicksAndRejections (internal/process/task_queues.js:93:5) {
      code: 'PLUGIN_ERROR',
      pluginCode: 'VALIDATION_ERROR',
      plugin: 'vite:build-html',
      hook: 'generateBundle'
    }
    Running terser
    Ran elm-review in 11111ms
    

I had a quick look but couldn't determine where this weird path is set, so I'm not sure how to correct it.

Footnotes

  1. Extract of error message:

    -- PROBLEM BUILDING DEPENDENCIES --------------- 
    I ran into a compilation error when trying to build the following package:
    
        avh4/elm-program-test 3.6.3
    
    This probably means it has package constraints that are too wide. It may be
    possible to tweak your elm.json to avoid the root problem as a stopgap. Head
    over to https://elm-lang.org/community to get help figuring out 
    how to take this
    path!
    
    Note: To help with the root problem, please report this to the package author
    along with the following information:
    
        avh4/elm-fifo 1.0.4
        elm/browser 1.0.2
        elm/core 1.0.5
        elm/html 1.0.0
        elm/http 2.0.0
        elm/json 1.1.3
        elm/parser 1.1.0
        elm/time 1.0.0
        elm/url 1.0.0
        elm-community/list-extra 8.3.0
        elm-explorations/test 1.2.2
        hecrj/html-parser 2.4.0
        mgold/elm-nonempty-list 4.2.0
    
    If you want to help out even more, try building the package locally. That should
    give you much more specific information about why this package is failing to
    build, which will in turn make it easier for the package author 
    to fix it!
    
    Note: Sometimes `lamdera reset` can fix this problem by rebuilding caches, so
    give that a try first.
    
@dillonkearns
Copy link
Owner

Hey @j-maas, thanks for the feedback! I added a note about lamdera reset and about installing the lamdera compiler to the readme instructions 👍

The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "../../../../../C:\Users\Johannes\Code\elm-pages-3-alpha-starter\elm-stuff\elm-pages\index.html"

This one seems like it's related to Windows vs. Unix file paths. I'm not sure exactly where it's coming from, it could be this line:

https://github.com/dillonkearns/elm-pages/blob/88f2a1dc14c8bf24d7c13fab328a452ac6a5389d/generator/src/build.js#L101-L103

Could you try changing that file locally in the elm-pages-3-alpha-starter/elm-pages/generators/src/build.js file and see if that changes anything? I'm not sure what the fix would be exactly. It seems like the issue is the ../../../, and the error message mentions rollup so that seems like the likely source of the problem.

@j-maas
Copy link
Author

j-maas commented Mar 19, 2022

Great tip! I think this is an issue in how Vite or Rollup handles Windows paths. At some point they use path.posix.relative, but one of the paths is Windows-style which leads to this error.

So it does not appear to be an issue with elm-pages, but rather something in Vite or Rollup. I will investigate further.

@j-maas j-maas closed this as completed Mar 19, 2022
@j-maas
Copy link
Author

j-maas commented Mar 19, 2022

Actually, the Windows-style path is the root given in the Vite config. So this is probably something you want to fix in elm-pages. I'll test out the actual fix (I'm getting errors about /style.css now) and will open a PR about this.

@j-maas j-maas reopened this Mar 19, 2022
@dillonkearns
Copy link
Owner

Oh, perfect, yes that would explain it! Thanks for trying that out, that's a big help 🙏

@j-maas
Copy link
Author

j-maas commented Mar 19, 2022

Actually I can't get it to behave correctly when converting the root to a POSIX-style path. I think this might be an upstream issue at Vite, since they hard-coded the POSIX-style there.

So for the time being, I'll close this issue again and maybe investigate on my own. ;)

And I'm happy to help in this way! You've done such amazing work, it's really great to be able to help out a little bit.

@j-maas j-maas closed this as completed Mar 19, 2022
@j-maas
Copy link
Author

j-maas commented Mar 19, 2022

Yep, when I change the line in the Vite code from const shortEmitName = path__default.posix.relative(config.root, id); to const shortEmitName = path__default.relative(config.root, id);, it works.

I will try to work out a fix upstream.

@j-maas
Copy link
Author

j-maas commented Mar 19, 2022

Opened a PR on Vite: vitejs/vite#7383

@dillonkearns
Copy link
Owner

Wow, great find! 👏 Thank you for digging into that and submitting a patch upstream!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants