Skip to content

Commit b4673aa

Browse files
committed
fix: attach path to json parse error
With a TODO to move this to the right place eventually
1 parent b7882c3 commit b4673aa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

workspaces/arborist/lib/arborist/load-actual.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// mix-in implementing the loadActual method
22

3-
const { relative, dirname, resolve, normalize } = require('node:path')
3+
const { dirname, join, normalize, relative, resolve } = require('node:path')
44

55
const PackageJson = require('@npmcli/package-json')
66
const { readdirScoped } = require('@npmcli/fs')
@@ -285,6 +285,10 @@ module.exports = cls => class ActualLoader extends cls {
285285
params.overrides = root.overrides.getNodeRule({ name: pkg.name, version: pkg.version })
286286
}
287287
} catch (err) {
288+
if (err.code === 'EJSONPARSE') {
289+
// TODO @npmcli/package-json should be doing this
290+
err.path = join(real, 'package.json')
291+
}
288292
params.error = err
289293
}
290294

0 commit comments

Comments
 (0)