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] Cannot destructure property 'name' of '.for' as it is undefined. #6006

Open
2 tasks done
cainytheslave opened this issue Dec 29, 2022 · 8 comments
Open
2 tasks done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release

Comments

@cainytheslave
Copy link

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
@cainytheslave cainytheslave added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Dec 29, 2022
@asuggula
Copy link

asuggula commented Feb 7, 2023

I'm running into the same exact issue - however this happens when I'm trying to link the package though (running npm link in the package directory).

@papaj-na-wrotkach
Copy link

I had the same problem when trying to install my project with npm install -g

I fixed it by providing "name" property in package.json

@GiemmeArnone
Copy link

GiemmeArnone commented Feb 20, 2024

@papaj-na-wrotkach can u be more specific, pls? 🥹

Because I started coding using Laravel this August, then I started and finished a React project. After completing the React project, I returned to work on the Laravel project, but I can't use 'npm run dev' because I used Vite on both projects. Then, I tried to update npm to fix the issue, but I ended up here

@papaj-na-wrotkach
Copy link

Sorry, it was a long time ago and I don't remember. I remember having problems with npm link and I think that I just edited package.json. I might have meant the global name property as in name of the project:

{
 "name": "my-project-name",
 "version": "1.0.0",
 "author": {
...
}

I remember that after setting the property npm link started working.

@umkl
Copy link

umkl commented Jul 9, 2024

I had the same problem when trying to install my project with npm install -g

I fixed it by providing "name" property in package.json

Thank you, such an obvious fix 😅

@danyaridiger
Copy link

danyaridiger commented Jul 31, 2024

If package name has been already provided but error hasn't gone i recommend restart console or terminal and run npm link again.

@CrackerakiUA
Copy link

CrackerakiUA commented Feb 15, 2025

In my case it was due to I started using environment, after I removed it all went smoothly

@semanser
Copy link

This can also happen due to the conflicts in the package-lock.json file. For some reason, sometimes, npm install fails to resolve them automatically. The solution is to discard some of the changes from one branch and run npm install again.

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

No branches or pull requests

8 participants