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

Build fails on Windows PowerShell with modern Node #1394

Open
louis75691710 opened this issue Jan 2, 2024 · 6 comments
Open

Build fails on Windows PowerShell with modern Node #1394

louis75691710 opened this issue Jan 2, 2024 · 6 comments

Comments

@louis75691710
Copy link

微信截图_20240102195854

@louis75691710
Copy link
Author

微信截图_20240102200402

@surma
Copy link
Collaborator

surma commented Jan 2, 2024

It looks like you are using PowerShell. I don’t think we support that well. Can you try with WSL?

@manishbluewebspark
Copy link

It looks like you are using PowerShell. I don’t think we support that well. Can you try with WSL?

Yes now its working thanks very much for quick help

@surma surma closed this as completed Jan 3, 2024
aryanpingle added a commit to aryanpingle/squoosh that referenced this issue Feb 3, 2024
* Resolves the "initial" CSS modules differently so that Windows users don't get a posix path
* Uses`initialCssModule` from initial-css-plugin to identify these modules
@aryanpingle
Copy link
Contributor

@surma Why do we not support Powershell again? Are there some commands or smth we're using that are linux specific?

@surma
Copy link
Collaborator

surma commented Aug 15, 2024

I think I was wrong, actually. @RReverser spent some time years ago adding support for PowerShell. In fact, we even run CI on Windows.

However, after I opened #1423, I learned that we only ever ran CI with Node 14 and that CI breaks on Windows with Node 22. The error looks very similar to what OP said, so we should prob investigate.

@surma surma reopened this Aug 15, 2024
@surma surma changed the title npm run build error Build fails on Windows PowerShell with modern Node Aug 15, 2024
@aryanpingle
Copy link
Contributor

There seems to be a typo in the resolve-dirs plugin, might be the root cause of the whole Windows-filepath issue? Lemme explain.

On my system the path to the squoosh dir is C:\\Projects\\Squoosh. Let's take one of the initial-css imports, import css0 from 'css:shared/prerendered-app/colors.css';. Here's a pseudo-log:

// (css-plugin)
"Resolving css:shared/prerendered-app/colors.css from initialCss"

// (resolve-dirs-plugin)
"Trying to resolve shared/prerendered-app/colors.css"
"Trying to resolve ./src/shared/prerendered-app/colors.css"
"Successfully resolved using this.resolve"
resolveResult = {
  external: true,
  id: './src/shared/prerendered-app/colors.css',
  meta: {},
  moduleSideEffects: true,
  syntheticNamedExports: false
}
// Not absolute, so return posix.resolve(resolveResult)
posix.resolve(resolveResult) // "/Projects/Squoosh/src/shared/prerendered-app/colors.css"

// (back to css-plugin)
return prefix + resolved.id; // "css:/Projects/Squoosh/src/shared/prerendered-app/colors.css"

And of course, the POSIX path does not exist on Windows, so we end up with this error:

[!] (plugin css) Error: Could not load css:/Projects/Squoosh/src/shared/prerendered-app/colors.css (imported by initialCss): Cannot find \Projects\Squoosh\src\shared\prerendered-app\colors.css in pathToResult


Using the fix shown in #1425, the logs will be the same except the ending:

// ...
// Not absolute, so return the path module's resolve(resolveResult) [the one that adjusts for the platform automatically]
resolve(resolveResult) // "C:\Projects\Squoosh\src\shared\prerendered-app\colors.css"

// (back to css-plugin)
return prefix + resolved.id; // "css:C:\Projects\Squoosh\src\shared\prerendered-app\colors.css"

Which correctly points to the CSS file. Tried it on both Windows and WSL, so fingers crossed.

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

4 participants