Clear and concise description of the problem
Hi
In some of my monorepo projects, I was facing Could not find root package.json error while trying to run node-modules-inspector right at the beginning.
At first I was surprised because npm query :root did find the root package.
After some investigation of the source code, it turns out there's some filtering happening :
return json.filter((pkg): pkg is NpmPackageNode => {
return (
pkg
&& typeof pkg === 'object'
&& typeof pkg._id === 'string'
&& typeof pkg.name === 'string'
&& typeof pkg.version === 'string'
)
})
So to be found, the root package.json needs both a name and version fields. In my case it was missing the later (sub-workspaces are versioned independently).
Suggested solution
When the Could not find root package.json is raised, maybe add a small explanation to help the user debug the situation more easily.
For example something like "Ensure that the root package.json has a name and a version"
Thanks
Alternative
No response
Additional context
No response
Validations
Clear and concise description of the problem
Hi
In some of my monorepo projects, I was facing
Could not find root package.jsonerror while trying to run node-modules-inspector right at the beginning.At first I was surprised because
npm query :rootdid find the root package.After some investigation of the source code, it turns out there's some filtering happening :
So to be found, the root package.json needs both a
nameandversionfields. In my case it was missing the later (sub-workspaces are versioned independently).Suggested solution
When the
Could not find root package.jsonis raised, maybe add a small explanation to help the user debug the situation more easily.For example something like "Ensure that the root package.json has a name and a version"
Thanks
Alternative
No response
Additional context
No response
Validations