Description
Description
Get package json files patterns - paths not normalized with older npm version
Version of syncpack: 9.8.4
OS: Windows
Package Manager: NPM
I have the following root package.json in a monorepo
{
"name": "ng-workspace-test",
"workspaces": [
"projects\\apps\\test-app1",
"projects\\apps\\test-app2",
"projects\\libs\\lib1",
"projects\\libs\\lib2",
"projects\\libs\\lib3"
],
...
"syncpack": {
"source": [
"projects/*/package.json"
]
}
}
workspaces are added through the commands (It was with an older npm version 7.24.2)
npm init -w ./projects/app/<name>
ornpm init -w ./projects/libs/<name>
this added the \\
slashes somehow, this is reproducible with npm i [email protected] -g
With a more current npm version 9.5.1 this is not happening anymore, than its like
...
"workspaces": [
"projects/apps/test-app1",
...
],
---
With the old workspaces config patterns are not matched and therefore no package.json files are found.
E.g. in get-file-paths.ts, then the pattern looks something like projects\libs\lib1/package.json
Suggested Solution
replace slashes in patterns pattern = pattern.replace(/\\/g, '/');
Note Glob patterns should always use / as a path separator, even on Windows systems...
https://github.com/isaacs/node-glob
Lines 39 to 41 in 2f1ffba
Workaround
For anyone using an older npm workspace configuration (maybe only on windows), replace the \\
slashes with /
fixes the Issue.