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> or
npm init -w ./projects/libs/<name>
this added the \\ slashes somehow, this is reproducible with npm i npm@7.24.2 -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
|
const ERR_GLOB_MISS = `No package.json files match pattern "${pattern}"`; |
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
|
globSync(pattern: string): string[] { |
|
verbose('globSync(', pattern, ')'); |
|
return globSync(pattern, { |
Workaround
For anyone using an older npm workspace configuration (maybe only on windows), replace the \\ slashes with / fixes the Issue.
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 withnpm i npm@7.24.2 -gWith a more current npm version 9.5.1 this is not happening anymore, than its like
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.jsonsyncpack/src/get-context/get-package-json-files/get-file-paths.ts
Line 38 in 2f1ffba
Suggested Solution
replace slashes in patterns
pattern = pattern.replace(/\\/g, '/');syncpack/src/lib/disk.ts
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.