Skip to content

fix(windows): normalize paths for cross-platform compatibility#652

Open
marcogomez-dev wants to merge 1 commit intonuejs:masterfrom
marcogomez-dev:fix/windows-path-normalization
Open

fix(windows): normalize paths for cross-platform compatibility#652
marcogomez-dev wants to merge 1 commit intonuejs:masterfrom
marcogomez-dev:fix/windows-path-normalization

Conversation

@marcogomez-dev
Copy link

@marcogomez-dev marcogomez-dev commented Dec 19, 2025

Summary

Add Windows path normalization for cross-platform compatibility.

Note: This is a rework of #631 which was closed accidentally when the fork was deleted.

Changes

  • Add toPosix() helper in fswalk.js to normalize paths at input boundaries
  • Normalize join() output in fswatch.js for directory watching events
  • Replace node:path sep with hardcoded / for consistent POSIX paths
  • Fix CRLF line endings in DHTML compiler for Windows compatibility
  • Update tests to use os.tmpdir() and join() for cross-platform compatibility

Problem

On Windows, path.relative() and file system APIs return backslash paths (blog\post.md), but the codebase uses POSIX patterns (blog/) for matching. This caused:

  • Blog and Docs entries not loading in /blog and /Docs
  • DHTML pages not rendering content on Windows due to CRLF line endings in scripts
  • Other path-based matching failures

Solution

Normalize all paths to POSIX format (/) at the input boundaries (fswalk.js and fswatch.js), so the rest of the system receives consistent paths.

Testing

  • All 489 tests pass on Windows
  • Manually verified: blog entries load, CSS loads, templates work
  • Pending verification in macOS/Linux

Related

Fixes #621
Fixes #628
Fixes #629

@marcogomez-dev marcogomez-dev force-pushed the fix/windows-path-normalization branch from ade0de1 to 5e3f7b6 Compare December 19, 2025 20:08
@germ1m1
Copy link

germ1m1 commented Jan 8, 2026

Using nue in windows environment i encountered the same problems as described here.

First i switched my files format from CRLF to LF and it fixed some problems but the nue integrated server still couldn't reach the generated ".html.js" files getting "Not found /ui/entry.html.js" typical messages.

Then i tried this fixed version and I can tell it now works perfectly : my nue project is now working like it shoulds, thank you @marcogomez-dev , i can now enjoy this delicious framework !

What is needed to get your merge request accepted into the original nue master branch ? Maybe some linux testing to check if it works on there as well ?

(i'm new to this and this comment is my first participation on github )

@germ1m1
Copy link

germ1m1 commented Jan 9, 2026

  • I've diggen deeper into the loading problem of the .html.js files on windows : it comes from one single line in the /nuekit/src/cmd/serve.js in the findAssetByURL function : the asset url is converted to a path without converting slash to backlash on windows environment. I've come with a simple and light fix that works perfectly on my side.

  • For the CRLF-line-ending related problem this can be avoid by saving project files in unix format (in VSCode : pick LF instead of CRLF in status bar for all your project files), or this can fixed patching Nue exactly like you did normalizing all '\r' in compileJS function in nuedom/src/compiler/compiler.js .

Here my fork with those two fixes compared to nue:master :
master...germ1m1:nue:fix-windows-asset-paths-and-CRLF-files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants