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

[BUG] npm error: Cannot destructure property name of 'undefined' or 'null'. #1832

Closed
joewood opened this issue Sep 19, 2020 · 18 comments
Closed
Assignees
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release

Comments

@joewood
Copy link

joewood commented Sep 19, 2020

Current Behavior:

When trying to install npm install react-scripts into a repo with typescript@^4.0.0 npm reports the following:

$ npm install react-scripts --save-dev
npm ERR! code ERESOLVE
npm ERR! Cannot destructure property `name` of 'undefined' or 'null'.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/joewood/.npm/_logs/2020-09-19T20_13_58_747Z-debug.log

Log file extract:

94 verbose node v12.14.1
195 verbose npm  v7.0.0-beta.11
196 error code ERESOLVE
197 verbose stack TypeError: Cannot destructure property `name` of 'undefined' or 'null'.
197 verbose stack     at printNode (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:26:9)
197 verbose stack     at explainNode (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:12:3)
197 verbose stack     at explainEresolve (/usr/local/lib/node_modules/npm/lib/utils/explain-eresolve.js:48:24)
197 verbose stack     at report (/usr/local/lib/node_modules/npm/lib/utils/explain-eresolve.js:75:3)
197 verbose stack     at module.exports (/usr/local/lib/node_modules/npm/lib/utils/error-message.js:16:24)
197 verbose stack     at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:165:15)
197 verbose stack     at /usr/local/lib/node_modules/npm/lib/npm.js:114:9
197 verbose stack     at install (/usr/local/lib/node_modules/npm/lib/install.js:69:5)
198 verbose cwd /Users/joewood/Documents/ttt
199 verbose Darwin 19.6.0
200 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "react-scripts" "--save-dev"
201 verbose node v12.14.1
202 verbose npm  v7.0.0-beta.11
203 error Cannot destructure property `name` of 'undefined' or 'null'.
204 verbose exit 1

Expected Behavior:

Install react-scripts as expected.

Steps To Reproduce:

In an empty directory:

$ npm init --yes
$ npm install typescript --save-dev
$ npm install react-scripts --save-dev
  • Node Version: v.12.14.1
  • NPM version: v7.0.0-beta.11
  • Default (no configuration)
  • Mac OS 10.15.6
@joewood joewood added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Sep 19, 2020
@darcyclarke
Copy link
Contributor

@joewood can you try updating to the latest npm (ie. npm i -g npm@next-7) & see if this is resolved for you now?

@darcyclarke darcyclarke removed the Needs Triage needs review for next steps label Oct 1, 2020
@ruyadorno
Copy link
Collaborator

hi @joewood thanks for the report! I tested your reproduction steps and can confirm it was broken in v7.0.0-beta.11 and it's now fixed on v7.0.0-rc.3 (latest next-7 release at the time of this comment).

Let us know in case you run into any new issues and thanks again for the help 😄

@joewood
Copy link
Author

joewood commented Oct 10, 2020

That fixed it, thanks!

@chenbimo
Copy link

chenbimo commented Nov 4, 2020

next-7 had an other problem similar this.

@mika350
Copy link

mika350 commented Dec 29, 2020

Downgrading to NPM version 6 solved the problem for me: npm i -g npm@6

@dmnsgn
Copy link

dmnsgn commented Jan 8, 2021

Encountering the same when trying to install a dependency from a GitHub URL.

$ npm -v
7.3.0

npm ERR! npm verb stack TypeError: Cannot destructure property 'name' of 'node' as it is null.

@ljharb
Copy link
Collaborator

ljharb commented Jan 8, 2021

What dependency?

@dmnsgn
Copy link

dmnsgn commented Jan 8, 2021

Can be reproduced with:

npm i -D git://github.com/GoogleChromeLabs/critters.git

@SamuelScheit
Copy link

SamuelScheit commented Jan 14, 2021

can be reproduced with:

npm i remount

On MacOS 10.15.7
Node: v15.5.0
NPM: npm@next-7 and npm@6 and npm@7.3.0

Error:

"npm" "i" "remount"
36 verbose node v15.5.0
37 verbose npm  v7.3.0
38 error code ERESOLVE
39 verbose stack TypeError: Cannot destructure property 'name' of 'node' as it is null.
39 verbose stack     at printNode (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:27:5)
39 verbose stack     at explainNode (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:12:3)
39 verbose stack     at explainEresolve (/usr/local/lib/node_modules/npm/lib/utils/explain-eresolve.js:24:24)
39 verbose stack     at report (/usr/local/lib/node_modules/npm/lib/utils/explain-eresolve.js:50:3)
39 verbose stack     at module.exports (/usr/local/lib/node_modules/npm/lib/utils/error-message.js:22:24)
39 verbose stack     at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:167:15)
39 verbose stack     at /usr/local/lib/node_modules/npm/lib/npm.js:121:9
...
Error: unable to resolve dependency tree
32 verbose stack     at Arborist.[failPeerConflict] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1061:25)
32 verbose stack     at Arborist.[placeDep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1145:30)
32 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:807:46
32 verbose stack     at Array.map (<anonymous>)
32 verbose stack     at Arborist.[buildDepStep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:807:8)
32 verbose stack     at async Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:209:7)
32 verbose stack     at async Promise.all (index 1)
32 verbose stack     at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:123:5)
32 verbose stack     at async install (/usr/local/lib/node_modules/npm/lib/install.js:38:3)

@isaacs
Copy link
Contributor

isaacs commented Jan 25, 2021

@dmnsgn @Flam3rboy These are new issues, not related to the original post's root cause (which has been fixed some time ago).

Can you please post a new issue so that we can triage this properly? Thanks. I'm digging into the repro cases you provided now.

@Cally99
Copy link

Cally99 commented Jan 28, 2021

I got this bug running a dependency install with yarn on a brand new repo pulled from github. Using docker-compose to build my app. No clue why. Will update when I find logs

@DavidTeachYouHowTo
Copy link

Downgrading to NPM version 6 solved the problem for me: npm i -g npm@6

It works for me too

@ruyadorno
Copy link
Collaborator

FYI @profesordavidvaldez @MikaBertels and anyone else landing on this issue in the future, instead of downgrading to a maintenance-only version, the recommended (and more future-proof) solution if you find yourself facing ERESOLVE errors that you can't fix yourself is to use the legacy-peer-deps config option.

You can add it to your .npmrc file and have it be the default for a given project:

$ echo "legacy-peer-deps=true" >> .npmrc

OR run the installer with the cli option: npm install --legacy-peer-deps

@ruyadorno
Copy link
Collaborator

ruyadorno commented Feb 4, 2021

For more info on the legacy-peer-deps option, here's the link to it in the docs: https://docs.npmjs.com/cli/v7/using-npm/config#legacy-peer-deps

@ostanioni
Copy link

alternatively, if you know what you are doing, then
npm i --force
e.g. peer dependency react 17.0.1 was overwritten to 17.0.2

@frederickjjoubert
Copy link

frederickjjoubert commented Mar 27, 2021

I was just having the same error trying to run ng add @ng-bootstrap/ng-bootstrap in an Angular 11 project.

I'm using node v15.4.0 and npm v7.6.3

I was able to use the following as a workaround: npm install --save @ng-bootstrap/ng-bootstrap --legacy-peer-deps

Pardon me for the lack of insight but I'm not sure what's causing the error or why/what --legacy-peer-deps does beyond the technical docs linked above but it allowed me to install bootstrap and continue with my day.

@advaithsuryaP
Copy link

I was just having the same error trying to run ng add @ng-bootstrap/ng-bootstrap in an Angular 11 project.

I'm using node v15.4.0 and npm v7.6.3

I was able to use the following as a workaround: npm install --save @ng-bootstrap/ng-bootstrap --legacy-peer-deps

Pardon me for the lack of insight but I'm not sure what's causing the error or why/what --legacy-peer-deps does beyond the technical docs linked above but it allowed me to install bootstrap and continue with my day.

Thanks for this mate !

@abhishek-bodapati
Copy link

FYI @profesordavidvaldez @MikaBertels and anyone else landing on this issue in the future, instead of downgrading to a maintenance-only version, the recommended (and more future-proof) solution if you find yourself facing ERESOLVE errors that you can't fix yourself is to use the legacy-peer-deps config option.

You can add it to your .npmrc file and have it be the default for a given project:

$ echo "legacy-peer-deps=true" >> .npmrc

OR run the installer with the cli option: npm install --legacy-peer-deps

Thanks man!

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

No branches or pull requests