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

fix(window): read file paths correctly in v14 on windows #262

Open
1 task done
stevebeauge opened this issue Feb 10, 2025 · 1 comment · May be fixed by #265
Open
1 task done

fix(window): read file paths correctly in v14 on windows #262

stevebeauge opened this issue Feb 10, 2025 · 1 comment · May be fixed by #265

Comments

@stevebeauge
Copy link

Syncpack version

[email protected]

Operating system(s)

Windows

Steps to reproduce

Under windows, in any node project run:

pnpx syncpack@alpha lint --show instances

or

npx syncpack@alpha lint --show instances

Expected behavior

Should works

Actual behavior

Both failed with this error:


pnpx syncpack@alpha lint --show instances --log-levels "error,warn,info,debug"                                                                                                                              

✗ There was an error when attempting to locate your syncpack rcfile
✗ Please raise an issue at https://github.com/JamieMason/syncpack/issues/new?template=bug_report.yaml
✗ node:internal/modules/cjs/loader:1143
  throw err;
  ^

Error: Cannot find module 'C:UserssteveAppDataLocalpnpm-cachedlxmbimy2fb4rrooqpixzweesu3em94eedae5fb-4ec0
[email protected][email protected]
ode_modulescosmiconfigdistindex.js'
Require stack:
- D:\code\myproject\[eval]
    at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
    at Module._load (node:internal/modules/cjs/loader:981:27)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:177:18)
    at [eval]:2:9
    at runScriptInThisContext (node:internal/vm:143:10)
    at node:internal/process/execution:100:14
    at [eval]-wrapper:6:24
    at runScript (node:internal/process/execution:83:62)
    at evalScript (node:internal/process/execution:114:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'D:\\code\\myproject\\[eval]' ]
}

Node.js v18.20.2

The behavior is the same both with or without a syncpackrc file.

Contents of syncpack configuration file

{
    "dependencyTypes": ["dev", "prod"]
}

Optional comments

I suspect there's something related to windows path using \ as path separators:

  • In the stack trace, folder structure is concatenated
  • I tested using wsl in the same project, and it works as expected / is used for path separator.

Not sure how syncpack works internally, but you may consider normalizing path to use / and not \ even on windows. These are valid path in windows, though not the default form.

Code of Conduct

@JamieMason
Copy link
Owner

Thanks a lot @stevebeauge, I've yet to try it in Windows, I'll get a VM set up 👍

@JamieMason JamieMason changed the title fix: version 14 (alpha) does not works on windows fix(window): read file paths correctly in v14 on windows Feb 10, 2025
@stevebeauge stevebeauge linked a pull request Feb 10, 2025 that will close this issue
stevebeauge pushed a commit to stevebeauge/syncpack that referenced this issue Feb 10, 2025
Encode path into json string to avoid backslash issues on windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants