[BUG] npm install on workspace: npm ERR! Cannot read property 'parent' of null`
Open
Nobody has claimed this yet.
Bug
Release 7.x
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
Runing npm install in the root of an npm workspace fails
"npm ERR! Cannot read property 'parent' of null"
Relevant section of the log:
4894 silly placeDep node_modules/yargs emoji-regex@8.0.0 OK for: string-width@4.2.2 want: ^8.0.0
4895 silly placeDep node_modules/yargs is-fullwidth-code-point@3.0.0 OK for: string-width@4.2.2 want: ^3.0.0
4896 timing idealTree:node_modules/yargs/node_modules/string-width Completed in 0ms
4897 timing idealTree:node_modules/yargs/node_modules/emoji-regex Completed in 0ms
4898 timing idealTree:node_modules/yargs/node_modules/is-fullwidth-code-point Completed in 0ms
4899 timing idealTree:node_modules/next/node_modules/jest-worker/node_modules/supports-color Completed in 0ms
4900 timing idealTree:node_modules/next/node_modules/supports-color/node_modules/has-flag Completed in 0ms
4901 silly placeDep node_modules/node-libs-browser/node_modules/assert inherits@2.0.1 OK for: util@0.10.3 want: 2.0.1
4902 timing idealTree:node_modules/node-libs-browser/node_modules/assert/node_modules/util Completed in 0ms
4903 timing idealTree:node_modules/node-libs-browser/node_modules/assert/node_modules/inherits Completed in 0ms
4904 timing idealTree:node_modules/send/node_modules/debug/node_modules/ms Completed in 0ms
4905 timing idealTree Completed in 5223ms
4906 timing command:install Completed in 5247ms
4907 verbose stack TypeError: Cannot read property 'parent' of null
4907 verbose stack at Arborist.[resolveLinks] (/home/nick/.nvm/versions/node/v16.4.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1887:39)
4907 verbose stack at Arborist.[buildDepStep] (/home/nick/.nvm/versions/node/v16.4.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:751:33)
4907 verbose stack at Arborist.[buildDepStep] (/home/nick/.nvm/versions/node/v16.4.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:921:31)
4908 verbose cwd /home/nick/development/projects/weightapp.git/dev
4909 verbose Linux 5.4.0-74-generic
4910 verbose argv "/home/nick/.nvm/versions/node/v16.4.1/bin/node" "/home/nick/.nvm/versions/node/v16.4.1/bin/npm" "install"
4911 verbose node v16.4.1
4912 verbose npm v7.19.1
4913 error Cannot read property 'parent' of null
4914 verbose exit 1
My project structure is
- apps
- | - api
- | - web
- libs
- | - ui
- | - comms
Workspaces in my root package.json are:
"workspaces": [
"apps/*",
"libs/*"
]
Expected Behavior
Ability to npm install in the root of a workspace with no error
Steps To Reproduce
- In a workspace
- Where packages depend on each-other
- Run
npm install - See error...
Environment
- OS: Ubuntu 20.04.02
- Node: v14.16.1 (also v16.0.0, 16.4.1)
- npm: 7.19.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the workspace install failure with npm 7.19.1 and inspect @npmcli/arborist/lib/arborist/build-ideal-tree.js, especially the resolveLinks and buildDepStep entry points shown in the stack trace. Confirm the failure for packages that depend on each other, then verify that npm install completes successfully without the null parent error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100