Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'length' of undefined (npm 7.0.8) #2134

Closed
lesyk-lesyk opened this issue Nov 6, 2020 · 8 comments
Closed

Cannot read property 'length' of undefined (npm 7.0.8) #2134

lesyk-lesyk opened this issue Nov 6, 2020 · 8 comments
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release

Comments

@lesyk-lesyk
Copy link

An error occurs during the installation of a new package.
Maybe relates to #2116

➜ git:(chore/npm-test) ✗ npm i --save-dev @graphql-codegen/typescript
npm ERR! code ERESOLVE
npm ERR! Cannot read property 'length' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/XXX/.npm/_logs/2020-11-06T11_25_39_984Z-debug.log

➜ node --version
v15.1.0

➜  npm --version
7.0.8

MacOS Catalina 10.15.7

Full log:
2020-11-06T11_25_39_984Z-debug.log

@darcyclarke darcyclarke added Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release labels Nov 6, 2020
@darcyclarke
Copy link
Contributor

Hey @okachynskyy! Sorry to hear you're having troubles. I just tried replicating this error & couldn't on the exact same setup (ie. os/node/npm version). Potentially, another dep you have in your tree is causing the problem or maybe has a peer conflict that can't be resolved (which is what the debug log seems to allude to). Can you try running that install again with either --force or using the legacy install behaviour w/ --legacy-peer-deps & see if that works/fixes anything?

@Kichrum
Copy link

Kichrum commented Nov 7, 2020

Have the same error on both 7.0.8 and 7.0.9 with a completely another setup (Angular 9 project), the error is quite not self-explanatory

TypeError: Cannot read property 'length' of undefined
  at explainDependents (/node/v15.1.0/lib/node_modules/npm/lib/utils/explain-dep.js:68:19)

--legacy-peer-deps fixes it, but I need a proper solution :)

@ebiton-eig
Copy link

I have the same problem with the package @angular/core (npm 7.0.9 and nodejs 15.1.0).

I used the command : ng update @angular/core :

`Using package manager: 'npm'
Collecting installed dependencies...
Found 55 dependencies.
Fetching dependency metadata from registry...
Updating package.json with dependency @angular/compiler-cli @ "10.2.2" (was "10.2.0")...
Updating package.json with dependency @angular/language-service @ "10.2.2" (was "10.2.0")...
Updating package.json with dependency @types/jasmine @ "3.6.1" (was "3.6.0")...
Updating package.json with dependency @angular/animations @ "10.2.2" (was "10.2.0")...
Updating package.json with dependency @angular/common @ "10.2.2" (was "10.2.0")...
Updating package.json with dependency @angular/compiler @ "10.2.2" (was "10.2.0")...
Updating package.json with dependency @angular/core @ "10.2.2" (was "10.2.0")...
Updating package.json with dependency @angular/forms @ "10.2.2" (was "10.2.0")...
Updating package.json with dependency @angular/localize @ "10.2.2" (was "10.2.0")...
Updating package.json with dependency @angular/platform-browser-dynamic @ "10.2.2" (was "10.2.0")...
Updating package.json with dependency @angular/router @ "10.2.2" (was "10.2.0")...
Updating package.json with dependency @angular/service-worker @ "10.2.2" (was "10.2.0")...
Updating package.json with dependency @ng-bootstrap/ng-bootstrap @ "8.0.0" (was "7.0.0")...
UPDATE package.json (2957 bytes)
\ Installing packages...npm ERR! code ERESOLVE
npm ERR! Cannot read property 'length' of undefined

npm ERR! C:\Users\edoua\AppData\Local\npm-cache_logs\2020-11-09T08_10_59_399Z-debug.log
× Package install failed, see above.
× Migration failed. See above for further details.`

2020-11-09T08_10_59_399Z-debug.log

@simllll
Copy link

simllll commented Nov 10, 2020

Same with latest npm (7.0.9) and --force flag:

134 timing idealTree Completed in 15778ms
135 timing command:install Completed in 15780ms
136 verbose stack TypeError: Cannot read property 'length' of undefined
136 verbose stack     at explainDependents (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:68:19)
136 verbose stack     at explainFrom (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:95:5)
136 verbose stack     at explainEdge (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:87:5)
136 verbose stack     at /usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:59:18
136 verbose stack     at Array.map (<anonymous>)
136 verbose stack     at explainDependents (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:59:6)
136 verbose stack     at explainNode (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:13:3)
136 verbose stack     at explainEresolve (/usr/local/lib/node_modules/npm/lib/utils/explain-eresolve.js:24:24)
136 verbose stack     at explain (/usr/local/lib/node_modules/npm/lib/utils/explain-eresolve.js:64:38)
136 verbose stack     at EventEmitter.log.warn (/usr/local/lib/node_modules/npm/lib/utils/setup-log.js:20:23)
137 verbose cwd /home/simon/Dev/hokify/hokify-server
138 verbose Linux 5.4.0-52-generic
139 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--unsafe-perm=true" "--allow-root"
140 verbose node v14.15.0
141 verbose npm  v7.0.9
142 error Cannot read property 'length' of undefined
143 verbose exit 1

But it seems it's happening in the bootstrap phase of lerna, if I adapt the paramters for the install paramter there, it also fails. Same stack trace:

136 verbose stack TypeError: Cannot read property 'length' of undefined
136 verbose stack     at explainDependents (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:68:19)
136 verbose stack     at explainFrom (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:95:5)
136 verbose stack     at explainEdge (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:87:5)
136 verbose stack     at /usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:59:18
136 verbose stack     at Array.map (<anonymous>)
136 verbose stack     at explainDependents (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:59:6)
136 verbose stack     at explainNode (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:13:3)
136 verbose stack     at explainEresolve (/usr/local/lib/node_modules/npm/lib/utils/explain-eresolve.js:24:24)
136 verbose stack     at explain (/usr/local/lib/node_modules/npm/lib/utils/explain-eresolve.js:64:38)
136 verbose stack     at EventEmitter.log.warn (/usr/local/lib/node_modules/npm/lib/utils/setup-log.js:20:23)
137 verbose cwd /home/simon/Dev/hokify/hokify-server
138 verbose Linux 5.4.0-52-generic
139 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--force"
140 verbose node v14.15.0
141 verbose npm  v7.0.9
142 error Cannot read property 'length' of undefined
143 verbose exit 1

The object that fails (explain-dep.js:68):

dependents[i] {
  type: 'dev',
  name: 'ts-loader',
  spec: '^8.0.10',
  from: { location: '/home/simon/Dev/hokify/hokify-server' }
}

it seems the from has no "name" property.

@isaacs
Copy link
Contributor

isaacs commented Nov 11, 2020

Can you share your package.json file and/or package-lock.json?

@isaacs
Copy link
Contributor

isaacs commented Nov 11, 2020

Nevermind, found it. Fixed on #2156.

@hiepxanh
Copy link

hope it will be fix soon, have the same error on 7.0.10 version

@rishabhpoddar
Copy link

I'm having this issue with all versions >= 7.0.7 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants