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 set property 'peer' of null #3711

Closed
1 task done
akornatskyy opened this issue Sep 2, 2021 · 25 comments
Closed
1 task done

[BUG] Cannot set property 'peer' of null #3711

akornatskyy opened this issue Sep 2, 2021 · 25 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release

Comments

@akornatskyy
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

npm -g ls --json:

npm ERR! Cannot set property 'peer' of null
{
  "error": {
    "code": null,
    "summary": "Cannot set property 'peer' of null",
    "detail": ""
  }
}

debug.log:

0 verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   '-g',
0 verbose cli   'ls',
0 verbose cli   '--json'
0 verbose cli ]
1 info using npm@7.21.0
2 info using node@v16.8.0
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 2ms
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:\.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 verbose config optional Use `--omit=optional` to exclude optional dependencies, or
11 verbose config `--include=optional` to include them.
11 verbose config
11 verbose config     Default value does install optional deps unless otherwise omitted.
12 timing config:load:file:C:\Users\Andriy_Kornatskyy\.npmrc Completed in 1ms
13 timing config:load:user Completed in 1ms
14 timing config:load:file:C:\Users\andriy_kornatskyy\AppData\Roaming\npm\etc\npmrc Completed in 0ms
15 timing config:load:global Completed in 0ms
16 timing config:load:validate Completed in 1ms
17 timing config:load:credentials Completed in 0ms
18 timing config:load:setEnvs Completed in 1ms
19 timing config:load Completed in 10ms
20 timing npm:load:configload Completed in 10ms
21 timing npm:load:setTitle Completed in 0ms
22 timing npm:load:setupLog Completed in 1ms
23 timing config:load:flatten Completed in 2ms
24 timing npm:load:cleanupLog Completed in 2ms
25 timing npm:load:configScope Completed in 0ms
26 timing npm:load:projectScope Completed in 0ms
27 timing npm:load Completed in 17ms
28 timing arborist:ctor Completed in 1ms
29 timing command:ls Completed in 416ms
30 verbose stack TypeError: Cannot set property 'peer' of null
30 verbose stack     at visit (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\calc-dep-flags.js:96:54)
30 verbose stack     at visitNode (C:\Program Files\nodejs\node_modules\npm\node_modules\treeverse\lib\depth-descent.js:57:25)
30 verbose stack     at next (C:\Program Files\nodejs\node_modules\npm\node_modules\treeverse\lib\depth-descent.js:44:19)
30 verbose stack     at depth (C:\Program Files\nodejs\node_modules\npm\node_modules\treeverse\lib\depth-descent.js:82:10)
30 verbose stack     at depth (C:\Program Files\nodejs\node_modules\npm\node_modules\treeverse\lib\depth.js:27:12)
30 verbose stack     at unsetFlag (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\calc-dep-flags.js:91:5)
30 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\calc-dep-flags.js:63:7
30 verbose stack     at Map.forEach (<anonymous>)
30 verbose stack     at calcDepFlagsStep (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\calc-dep-flags.js:40:17)
30 verbose stack     at visit (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\calc-dep-flags.js:12:20)
31 verbose cwd C:\
32 verbose Windows_NT 10.0.19042
33 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "-g" "ls" "--json"
34 verbose node v16.8.0
35 verbose npm  v7.21.0
36 error Cannot set property 'peer' of null
37 verbose exit 1

Expected Behavior

No response

Steps To Reproduce

No response

Environment

  • OS: Windows 10
  • Node: 16.8.0
  • npm: 7.21.0
@akornatskyy akornatskyy 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 2, 2021
@ghost
Copy link

ghost commented Sep 10, 2021

Just hit upon what seems to be exactly the same issue so it is definitely reproducible on another platform.

  • OS: LinuxMint
  • Node: 14.17.6
  • npm: 7.23.0

Additional info: I'm using npm workspaces setup in mymonorepo/package.json

Unfortunately it's a big project so it's difficult to isolate what's the basic precursor to the problem is.

Strangely, I ran npm install in the root monorepo directory mymonorepo with success on the first 3 occasions. 30 minutes later, without changing anything in the project (according to git) this problem
npm ERR! Cannot set property 'peer' of null
appeared out of nowhere.

Have tried deleting '.npmand.cache\npm` in my home directory and the problem persists.

For comparison I checked installing via yarn and all was well.

Tail of npm log file:

2687 verbose stack TypeError: Cannot set property 'peer' of null
2687 verbose stack     at visit (/home/xyz/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:104:54)
2687 verbose stack     at visitNode (/home/xyz/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:57:25)
2687 verbose stack     at next (/home/xyz/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:44:19)
2687 verbose stack     at depth (/home/xyz/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:82:10)
2687 verbose stack     at depth (/home/xyz/lib/node_modules/npm/node_modules/treeverse/lib/depth.js:27:12)
2687 verbose stack     at unsetFlag (/home/xyz/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:99:5)
2687 verbose stack     at /home/xyz/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:65:7
2687 verbose stack     at Map.forEach (<anonymous>)
2687 verbose stack     at calcDepFlagsStep (/home/xyz/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:41:17)
2687 verbose stack     at visit (/home/xyz/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:12:20)
2688 verbose cwd /home/xyz/mymonorepo
2689 verbose Linux 5.4.0-84-generic
2690 verbose argv "/home/xyz/bin/node" "/home/xyz/bin/npm" "install"
2691 verbose node v14.17.6
2692 verbose npm  v7.23.0
2693 error Cannot set property 'peer' of null
2694 verbose exit 1

@koush
Copy link

koush commented Sep 21, 2021

Hit this issue. Updating npm seemed to resolve it.
Before

info using npm@7.20.3

after:
7.24.0

@akornatskyy
Copy link
Author

still the issue with 7.24.0.

$ npm ls --json --global
npm ERR! Cannot set properties of null (setting 'peer')
{
  "error": {
    "code": null,
    "summary": "Cannot set properties of null (setting 'peer')",
    "detail": ""
  }
}

@akornatskyy
Copy link
Author

As a workaround I have removed ~\AppData\Roaming\npm and reinstalled node.

@lfowlie
Copy link

lfowlie commented Oct 6, 2021

I'm running into something similar running npm version 7.24.2. Verbose stack trace:

#15 6.035 npm timing command:install Completed in 5708ms
#15 6.037 npm verb stack TypeError: Cannot set property 'dev' of null
#15 6.037 npm verb stack     at calcDepFlagsStep (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:34:21)
#15 6.037 npm verb stack     at visit (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:12:20)
#15 6.037 npm verb stack     at visitNode (/usr/local/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:57:25)
#15 6.037 npm verb stack     at next (/usr/local/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:44:19)
#15 6.037 npm verb stack     at depth (/usr/local/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:82:10)
#15 6.037 npm verb stack     at depth (/usr/local/lib/node_modules/npm/node_modules/treeverse/lib/depth.js:27:12)
#15 6.037 npm verb stack     at calcDepFlags (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:10:15)
#15 6.037 npm verb stack     at Arborist.[copyIdealToActual] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:1375:7)
#15 6.037 npm verb stack     at Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:151:35)
#15 6.037 npm verb stack     at async Install.install (/usr/local/lib/node_modules/npm/lib/install.js:170:5)
#15 6.037 npm verb cwd /usr/src
#15 6.038 npm verb Linux 5.10.47-linuxkit
#15 6.038 npm verb argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--workspace=scheduler" "--loglevel" "verbose"
#15 6.038 npm verb node v14.16.1
#15 6.038 npm verb npm  v7.24.2
#15 6.039 npm ERR! Cannot set property 'dev' of null
#15 6.040 npm verb exit 1
#15 6.079 npm timing npm Completed in 5852ms
#15 6.079 npm verb unfinished npm timer reify 1633559282223
#15 6.079 npm verb code 1

Also using workspaces similar to @indiescripter. Was there a resolution for this? Any reason it was closed?

@ghost
Copy link

ghost commented Oct 7, 2021

I eventually gave up and have been using pnpm for a while now just to keep moving along.

Between npm, pnpm & yarn I think the package manager ecosystem is in a very bad place right now.

There doesn't seem to be a proper explanation for closing the issue though.

@dhalbrook
Copy link

I'm running into this attempting to update "pino-pretty" in a child workspace. It fails with both npm 7.24.2 and 8.1.0:

Cannot set properties of null (setting 'dev')

@pedroabreu
Copy link

npm verb stack TypeError: Cannot set properties of null (setting 'dev')
npm verb stack     at calcDepFlagsStep (/Users/pedroabreu/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:34:21)
npm verb stack     at visit (/Users/pedroabreu/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:12:20)
npm verb stack     at visitNode (/Users/pedroabreu/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:57:25)
npm verb stack     at next (/Users/pedroabreu/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:44:19)
npm verb stack     at depth (/Users/pedroabreu/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:82:10)
npm verb stack     at depth (/Users/pedroabreu/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/treeverse/lib/depth.js:27:12)
npm verb stack     at calcDepFlags (/Users/pedroabreu/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:10:15)
npm verb stack     at Arborist.[copyIdealToActual] (/Users/pedroabreu/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:1400:7)
npm verb stack     at Arborist.reify (/Users/pedroabreu/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:153:35)
npm verb stack     at async CI.ci (/Users/pedroabreu/.nvm/versions/node/v16.13.0/lib/node_modules/npm/lib/ci.js:74:5)
npm verb cwd /Users/pedroabreu/Documents/home
npm verb Darwin 21.1.0

Running into the same when running npm ci --workspace=x. If I run npm run install --workspace=x right after it does complete 🤷

Node: 16.13.0
npm: 8.1.0

@lfowlie
Copy link

lfowlie commented Nov 22, 2021

Solution for me was downgrading to npm@7.18.1
#3847

@Adjective-Object
Copy link

Some developers in our org are hitting this inconsistently. The most recent repro we have is:

"C:\Program Files\nodejs\npx" "midgard-yarn@1.23.33"
npm ERR! Cannot set property 'peer' of null

node@v14.18.1
npm@8.1.2

Having difficulty getting more info out of the dev that hit this error than that.

From looking at the logs here it looks like this is happening in arborist here:
https://github.com/npm/arborist/blob/main/lib/calc-dep-flags.js#L104

so target is unset on a node with isLinked=true.

Which seems to only execute on 'isLinked' modules. (I assume modules that have been npm linked)
https://github.com/npm/arborist/blob/main/lib/calc-dep-flags.js#L33-L39

@Adjective-Object
Copy link

For anyone else reading this thread, we, for the most part, use midgard-yarn for our project management, but execute it via npx in some scenarios. I'm not sure how npm checks linking, but if it's based on the current state of the disk rather, then is it possible that yarn's symlinks are confusing npm?

Just wildly speculating here.

@minecrawler
Copy link

After having a working npm for years and not changing the config, I just ran into it on node v8.1.4. Upgraded to v8.5.4 and the problem did not go away. Log:

42 verbose stack TypeError: Cannot set properties of null (setting 'peer')
42 verbose stack     at visit (C:\Users\<user>\AppData\Roaming\nvm\v17.2.0\node_modules\npm\node_modules\@npmcli\arborist\lib\calc-dep-flags.js:104:54)
42 verbose stack     at visitNode (C:\Users\<user>\AppData\Roaming\nvm\v17.2.0\node_modules\npm\node_modules\treeverse\lib\depth-descent.js:57:25)
42 verbose stack     at next (C:\Users\<user>\AppData\Roaming\nvm\v17.2.0\node_modules\npm\node_modules\treeverse\lib\depth-descent.js:44:19)
42 verbose stack     at depth (C:\Users\<user>\AppData\Roaming\nvm\v17.2.0\node_modules\npm\node_modules\treeverse\lib\depth-descent.js:82:10)
42 verbose stack     at depth (C:\Users\<user>\AppData\Roaming\nvm\v17.2.0\node_modules\npm\node_modules\treeverse\lib\depth.js:27:12)
42 verbose stack     at unsetFlag (C:\Users\<user>\AppData\Roaming\nvm\v17.2.0\node_modules\npm\node_modules\@npmcli\arborist\lib\calc-dep-flags.js:99:5)
42 verbose stack     at C:\Users\<user>\AppData\Roaming\nvm\v17.2.0\node_modules\npm\node_modules\@npmcli\arborist\lib\calc-dep-flags.js:65:7
42 verbose stack     at Map.forEach (<anonymous>)
42 verbose stack     at calcDepFlagsStep (C:\Users\<user>\AppData\Roaming\nvm\v17.2.0\node_modules\npm\node_modules\@npmcli\arborist\lib\calc-dep-flags.js:41:17)
42 verbose stack     at visit (C:\Users\<user>\AppData\Roaming\nvm\v17.2.0\node_modules\npm\node_modules\@npmcli\arborist\lib\calc-dep-flags.js:12:20)
43 verbose cwd C:\Users\<user>\tmp
44 verbose Windows_NT 10.0.19042
45 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i" "<CLASSIFIED>"
46 verbose node v17.2.0
47 verbose npm  v8.5.4
48 error Cannot set properties of null (setting 'peer')
49 verbose exit 1

The "solution" by @akornatskyy (delete folder and reinstall node) is not really a fix for the root cause, and I think this needs more investigation, since people still hit the bug!

@akornatskyy
Copy link
Author

@minecrawler: there is no "solution" for this issue yet, I have suggested just a workaround. However, with a new node update the issue is back, so it still requires a fix.

@HolgerSeith
Copy link

@minecrawler: there is no "solution" for this issue yet, I have suggested just a workaround. However, with a new node update the issue is back, so it still requires a fix.

So why not re-opening it again ?

@alexander233
Copy link

Please reopen. Issue persists on NPM v8.5.5. This is a showstopper.

@charliekassel
Copy link

Also seeing this with v8.7.0

@jakebanks
Copy link

Seeing it on 8.8.0, somehow deleting node_modules worked around the issue

@kennyh-tbg
Copy link

I had the same issue. It turned out that one of my dependencies, a local one, had a dependency on a package that did not exist (locally). It was odd because the first time I did an install after wiping node_modules and package-lock.json it would work fine. If I tried to re-install it would fail with the error above.

@benlongo
Copy link

I think this happens if you change the name in package.json for local deps. Deleting node_modules worked for me 🤷

@giacomogagliano
Copy link

giacomogagliano commented Jun 15, 2022

I have the same issue, I was using npm 8.5.5.

  1. I upgraded to npm 8.12.1 and I still get the same error.
  2. I tried on a new project with a workspace and it works.

I was importing a package folder this way: {... workspace:["<package_folder>/**/*"], instead:

  1. i tried importing each an every single folder that there is in the <package_folder> and it works fine.
  2. I tried this as path in the workspace array: <package>/**, it didn't work
  3. I tried <package>/* and it works!

I don't know exactly but there must me something inside those folders that It didn't like!
I have to be honest I don't know exactly the difference between /** and /*, probably it works cause it cannot find something to install. I will investigate 😅

@minecrawler
Copy link

@giacomogagliano I opened a new bug report, since the author of this one refuses to re-open. You can write down your request over there: #5007

@KEMBL
Copy link

KEMBL commented Apr 14, 2023

the same issue
npm v9.6.4
node v18.15.0
monorepo
Windows v10

npm install
npm ERR! Cannot set properties of null (setting 'peer')

@kirkstrobeck
Copy link

kirkstrobeck commented Jul 3, 2023

Fix for me was to delete node_modules and then npm i

@garhbod
Copy link

garhbod commented Nov 1, 2023

I had to also clear npm cache with npm cache clean --force then delete node_modules and run npm i

@douglasg14b
Copy link

douglasg14b commented Aug 27, 2024

This error is appearing while using pnpm for me, builds fail :/

13 verbose stack TypeError: Cannot set properties of null (setting 'peer')
13 verbose stack     at visit (/home/douglas/.nvm/versions/node/v20.12.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:101:54)
13 verbose stack     at visitNode (/home/douglas/.nvm/versions/node/v20.12.2/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:58:25)
13 verbose stack     at next (/home/douglas/.nvm/versions/node/v20.12.2/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:44:19)
13 verbose stack     at depth (/home/douglas/.nvm/versions/node/v20.12.2/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:83:10)
13 verbose stack     at depth (/home/douglas/.nvm/versions/node/v20.12.2/lib/node_modules/npm/node_modules/treeverse/lib/depth.js:27:12)
13 verbose stack     at unsetFlag (/home/douglas/.nvm/versions/node/v20.12.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:96:5)
13 verbose stack     at /home/douglas/.nvm/versions/node/v20.12.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:63:7
13 verbose stack     at CIMap.forEach (<anonymous>)
13 verbose stack     at calcDepFlagsStep (/home/douglas/.nvm/versions/node/v20.12.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:41:17)
13 verbose stack     at calcDepFlagsStep (/home/douglas/.nvm/versions/node/v20.12.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:38:12)

Actually, appears this happens during npm exec copyfiles

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 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests