npm / npm/cli

[BUG] Cannot destructure property 'name' of '.for' as it is undefined.

Open
#6,006 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage Release 9.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
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior

Disclaimer:

  • I reinstalled Node multiple times with different versions and it didn't work (deleting all npm appdata files)
  • I tried using nvm (in this example) also didn't work
  • I restarted my pc :D

Today when I wanted to get started coding, I created a brand new Laravel project and tried using npm. npm then informed me that a new version was out and I should upgrade, so I did:

npm install -g npm@latest

And got provided with v9.2.0. Before that I was using npm 8.

After the upgrade I wanted to install my packages so I did:

npm install

Then I got hit by this:

npm ERR! Cannot destructure property 'name' of '.for' as it is undefined.

The full error log is as follows:

0 verbose cli C:\nvm4w\node.exe C:\nvm4w\node_modules\npm\bin\npm-cli.js
1 info using npm@9.2.0
2 info using node@v19.3.0
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 3ms
5 timing config:load:file:C:\Users\johnw\AppData\Roaming\nvm\v19.3.0\node_modules\npm\npmrc Completed in 1ms
6 timing config:load:builtin Completed in 2ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\Workspaces\Laravel\projectx\.npmrc Completed in 1ms
10 timing config:load:project Completed in 3ms
11 timing config:load:file:C:\Users\johnw\.npmrc Completed in 2ms
12 timing config:load:user Completed in 2ms
13 timing config:load:file:C:\nvm4w\etc\npmrc Completed in 1ms
14 timing config:load:global Completed in 1ms
15 timing config:load:setEnvs Completed in 1ms
16 timing config:load Completed in 15ms
17 timing npm:load:configload Completed in 15ms
18 timing npm:load:mkdirpcache Completed in 1ms
19 timing npm:load:mkdirplogs Completed in 1ms
20 verbose title npm install
21 verbose argv "install"
22 timing npm:load:setTitle Completed in 1ms
23 timing config:load:flatten Completed in 4ms
24 timing npm:load:display Completed in 6ms
25 verbose logfile logs-max:10 dir:C:\Users\johnw\AppData\Local\npm-cache\_logs\2022-12-29T17_20_32_474Z-
26 verbose logfile C:\Users\johnw\AppData\Local\npm-cache\_logs\2022-12-29T17_20_32_474Z-debug-0.log
27 timing npm:load:logFile Completed in 22ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 48ms
31 timing config:load:flatten Completed in 1ms
32 timing arborist:ctor Completed in 1ms
33 silly logfile start cleaning logs, removing 2 files
34 silly logfile done cleaning log files
35 timing idealTree:init Completed in 12ms
36 timing idealTree:userRequests Completed in 7ms
37 silly idealTree buildDeps
38 silly fetch manifest undefined@file:../../../../../../Workspaces/Laravel/projectx
39 silly placeDep ROOT undefined@ OK for:  want: file:../../../../../../Workspaces/Laravel/projectx
40 timing idealTree:#root Completed in 9ms
41 timing idealTree:node_modules/undefined Completed in 0ms
42 timing idealTree:buildDeps Completed in 11ms
43 timing idealTree:fixDepFlags Completed in 1ms
44 timing idealTree Completed in 31ms
45 timing reify:loadTrees Completed in 36ms
46 timing command:install Completed in 47ms
47 verbose stack TypeError: Cannot destructure property 'name' of '.for' as it is undefined.
47 verbose stack     at [diffTrees] (C:\Users\johnw\AppData\Roaming\nvm\v19.3.0\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:336:20)
47 verbose stack     at Arborist.reify (C:\Users\johnw\AppData\Roaming\nvm\v19.3.0\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:157:27)
47 verbose stack     at async Install.exec (C:\Users\johnw\AppData\Roaming\nvm\v19.3.0\node_modules\npm\lib\commands\install.js:146:5)
47 verbose stack     at async module.exports (C:\Users\johnw\AppData\Roaming\nvm\v19.3.0\node_modules\npm\lib\cli.js:133:5)
48 verbose cwd C:\Workspaces\Laravel\projectx
49 verbose Windows_NT 10.0.22000
50 verbose node v19.3.0
51 verbose npm  v9.2.0
52 error Cannot destructure property 'name' of '.for' as it is undefined.
53 verbose exit 1
54 timing npm Completed in 133ms
55 verbose unfinished npm timer reify 1672334432557
56 verbose unfinished npm timer reify:diffTrees 1672334432598
57 verbose code 1
58 error A complete log of this run can be found in:
58 error     C:\Users\johnw\AppData\Local\npm-cache\_logs\2022-12-29T17_20_32_474Z-debug-0.log

Expected Behavior

I would expect that the dependencies just installed because it was a clean fresh package.json with just a few devDependecies..

I tried then to downgrade to v8, also didn't work anymore.
I tried then to downgrade to v7, this again worked but gave some errors due to too old of an version.

Steps To Reproduce
  1. On a fresh install of npm, either via node or via nvm4w (I tried both) create a new Laravel Project
  2. It doesn't matter what is inside my package.json, or whether there is a package-lock or node_modules folder
  3. Run 'npm install'
  4. See the error: Cannot destructure property 'name' of '.for' as it is undefined.
Environment
  • npm -v: 9.2.0
  • node -v: 19.3.0
  • OS Name: Windows 11
  • System Model Name: Lenovo Legion Y520

npm config ls:

location = "global"
; node bin location = C:\nvm4w\node.exe
; node version = v19.3.0
; npm local prefix = C:\Workspaces\Laravel\projectx
; npm version = 9.2.0
; cwd = C:\Workspaces\Laravel\projectx
; HOME = C:\Users\johnw

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with npm 9.2.0, Node v19.3.0, and the provided Laravel project setup, then inspect @npmcli/arborist/lib/arborist/reify.js at line 336 from the stack trace. Use the verbose log and the npm install path as the baseline; done means npm install completes successfully for the reported project without the destructuring error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.