npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.46k stars 3.15k forks source link

[BUG] npm install on workspace: npm ERR! Cannot read property 'parent' of null` #3500

Open NickKelly1 opened 3 years ago

NickKelly1 commented 3 years ago

Is there an existing issue for this?

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

  1. In a workspace
  2. Where packages depend on each-other
  3. Run npm install
  4. See error...

Environment

livthomas commented 3 years ago

I also get the same error when I try to update the dependencies in my project.

ruyadorno commented 2 years ago

Thanks for reporting it @NickKelly1!

Is this still the case with the current version? npm@8.3.2 at the moment of writing. If yes it would be very appreciated if you could provide more info, specially a minimal reproduction of the problem so that we can better prioritize this issue in our backlog.

potados99 commented 2 years ago

Same issue here.