cli
cli copied to clipboard
[BUG] Cannot destructure property 'name' of '.for' as it is undefined.
Is there an existing issue for this?
- [X] I have searched the existing issues
This issue exists in the latest npm version
- [X] 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 [email protected]
2 info using [email protected]
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
- On a fresh install of npm, either via node or via nvm4w (I tried both) create a new Laravel Project
- It doesn't matter what is inside my
package.json, or whether there is a package-lock or node_modules folder - Run 'npm install'
- 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
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).
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
@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
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.
I had the same problem when trying to install my project with
npm install -gI fixed it by providing
"name"property inpackage.json
Thank you, such an obvious fix 😅
If package name has been already provided but error hasn't gone i recommend restart console or terminal and run npm link again.