Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Running npm version <inc> --include-workspace-root --workspaces throws npm ERR! Cannot read properties of undefined (reading '0') if the workspace root doesn't have a name field in its package.json.
Expected Behavior
The version command should not throw an error if the workspace root doesn't have a name field.
Steps To Reproduce
package.json:
{
"workspaces": [
"packages/*"
],
"version": "1.3.0"
}
packages/one/package.json:
{
"name": "one",
"version": "1.3.0"
}
Running npm version minor --include-workspace-root --workspaces gives the following error:
undefined
v1.4.0
one
v1.4.0
npm ERR! Cannot read properties of undefined (reading '0')
Upon adding a name field to the workspace root, the command succeeds:
package.json:
{
"name": "root",
"workspaces": [
"packages/*"
],
"version": "1.4.0"
}
npm version minor --include-workspace-root --workspaces:
Environment
- npm: 8.19.2
- Node.js: v16.17.0
- OS Name: macOS Monterey 12.5.1
- System Model Name: Macbook Pro
- npm config:
; node bin location = /Users/msrose/.nvm/versions/node/v16.17.0/bin/node
; node version = v16.17.0
; npm local prefix = /Users/msrose/test-stuff/test-npm-bug
; npm version = 8.19.2
; cwd = /Users/msrose/test-stuff/test-npm-bug
; HOME = /Users/msrose
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Running
npm version <inc> --include-workspace-root --workspacesthrowsnpm ERR! Cannot read properties of undefined (reading '0')if the workspace root doesn't have anamefield in its package.json.Expected Behavior
The
versioncommand should not throw an error if the workspace root doesn't have anamefield.Steps To Reproduce
package.json:
packages/one/package.json:
Running
npm version minor --include-workspace-root --workspacesgives the following error:Upon adding a
namefield to the workspace root, the command succeeds:package.json:
npm version minor --include-workspace-root --workspaces:Environment