ERESOLVE unable to resolve dependency tree

I want to install the package Pinia for my Vue3 app. To setup the project I run these commands:

vue create foo

# select default Vue 3

cd foo

npm install pinia

Unfortunately I get this error

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: foo@0.1.0
npm ERR! Found: vue@3.2.20
npm ERR! node_modules/vue
npm ERR!   vue@"^3.0.0" from the root project
npm ERR!   peer vue@"^2.6.14 || ^3.2.0" from pinia@2.0.0-rc.13
npm ERR!   node_modules/pinia
npm ERR!     pinia@"*" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer vue@">= 2.5 < 3" from @vue/composition-api@1.2.4
npm ERR! node_modules/@vue/composition-api
npm ERR!   peerOptional @vue/composition-api@"^1.2.4" from pinia@2.0.0-rc.13
npm ERR!   node_modules/pinia
npm ERR!     pinia@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

The information from eresolve-report.txt

# npm resolution error report

2021-10-16T16:19:15.751Z

While resolving: foo@0.1.0
Found: vue@3.2.20
node_modules/vue
  vue@"^3.0.0" from the root project
  peer vue@"^2.6.14 || ^3.2.0" from pinia@2.0.0-rc.13
  node_modules/pinia
    pinia@"*" from the root project

Could not resolve dependency:
peer vue@">= 2.5 < 3" from @vue/composition-api@1.2.4
node_modules/@vue/composition-api
  peerOptional @vue/composition-api@"^1.2.4" from pinia@2.0.0-rc.13
  node_modules/pinia
    pinia@"*" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

Raw JSON explanation object:

{
  "code": "ERESOLVE",
  "current": {
    "name": "vue",
    "version": "3.2.20",
    "whileInstalling": {
      "name": "foo",
      "version": "0.1.0",
      "path": "/home/.../foo"
    },
    "location": "node_modules/vue",
    "dependents": [
      {
        "type": "prod",
        "name": "vue",
        "spec": "^3.0.0",
        "from": {
          "location": "/home/.../foo"
        }
      },
      {
        "type": "peer",
        "name": "vue",
        "spec": "^2.6.14 || ^3.2.0",
        "from": {
          "name": "pinia",
          "version": "2.0.0-rc.13",
          "whileInstalling": {
            "name": "foo",
            "version": "0.1.0",
            "path": "/home/.../foo"
          },
          "location": "node_modules/pinia",
          "dependents": [
            {
              "type": "prod",
              "name": "pinia",
              "spec": "*",
              "from": {
                "location": "/home/.../foo"
              }
            }
          ]
        }
      }
    ]
  },
  "edge": {
    "type": "peer",
    "name": "vue",
    "spec": ">= 2.5 < 3",
    "error": "INVALID",
    "from": {
      "name": "@vue/composition-api",
      "version": "1.2.4",
      "whileInstalling": {
        "name": "foo",
        "version": "0.1.0",
        "path": "/home/.../foo"
      },
      "location": "node_modules/@vue/composition-api",
      "dependents": [
        {
          "type": "peerOptional",
          "name": "@vue/composition-api",
          "spec": "^1.2.4",
          "from": {
            "name": "pinia",
            "version": "2.0.0-rc.13",
            "whileInstalling": {
              "name": "foo",
              "version": "0.1.0",
              "path": "/home/.../foo"
            },
            "location": "node_modules/pinia",
            "dependents": [
              {
                "type": "prod",
                "name": "pinia",
                "spec": "*",
                "from": {
                  "location": "/home/.../foo"
                }
              }
            ]
          }
        }
      ]
    }
  },
  "peerConflict": null,
  "strictPeerDeps": false,
  "force": false
}

The information from 2021-10-16T16_19_15_753Z-debug.log

0 verbose cli [ '/usr/bin/node', '/usr/local/bin/npm', 'install', 'pinia' ]
1 info using npm@7.5.2
2 info using node@v14.18.1
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
5 timing config:load:builtin Completed in 1ms
6 timing config:load:cli Completed in 0ms
7 timing config:load:env Completed in 1ms
8 timing config:load:file:/home/.../foo/.npmrc Completed in 0ms
9 timing config:load:project Completed in 0ms
10 timing config:load:file:/home/.../.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 4ms
19 verbose npm-session 610e1bfdd7128481
20 timing npm:load Completed in 7ms
21 timing arborist:ctor Completed in 0ms
22 timing idealTree:init Completed in 269ms
23 timing idealTree:userRequests Completed in 1ms
24 silly idealTree buildDeps
25 silly fetch manifest pinia@*
26 http fetch GET 304 https://registry.npmjs.org/pinia 875ms (from cache)
27 silly fetch manifest @vue/composition-api@^1.2.4
28 http fetch GET 304 https://registry.npmjs.org/@vue%2fcomposition-api 1455ms (from cache)
29 silly fetch manifest vue@^3.0.0
30 http fetch GET 200 https://registry.npmjs.org/vue 3ms (from cache)
31 silly fetch manifest vue@>= 2.5 < 3
32 timing idealTree Completed in 2619ms
33 timing command:install Completed in 2620ms
34 verbose stack Error: unable to resolve dependency tree
34 verbose stack     at Arborist.[failPeerConflict] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1115:25)
34 verbose stack     at Arborist.[loadPeerSet] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1095:34)
34 verbose stack     at async Arborist.[loadPeerSet] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1073:11)
34 verbose stack     at async Arborist.[buildDepStep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:824:11)
34 verbose stack     at async Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:209:7)
34 verbose stack     at async Promise.all (index 1)
34 verbose stack     at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:127:5)
34 verbose stack     at async install (/usr/local/lib/node_modules/npm/lib/install.js:38:3)
35 verbose cwd /home/.../foo
36 verbose Linux 5.13.0-7614-generic
37 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "install" "pinia"
38 verbose node v14.18.1
39 verbose npm  v7.5.2
40 error code ERESOLVE
41 error ERESOLVE unable to resolve dependency tree
42 error
43 error While resolving: e[1mfooe[22m@e[1m0.1.0e[22m
43 error Found: e[1mvuee[22m@e[1m3.2.20e[22me[2me[22m
43 error e[2mnode_modules/vuee[22m
43 error   e[1mvuee[22m@"e[1m^3.0.0e[22m" from the root project
43 error   e[35mpeere[39m e[1mvuee[22m@"e[1m^2.6.14 || ^3.2.0e[22m" from e[1mpiniae[22m@e[1m2.0.0-rc.13e[22me[2me[22m
43 error   e[2mnode_modules/piniae[22m
43 error     e[1mpiniae[22m@"e[1m*e[22m" from the root project
43 error
43 error Could not resolve dependency:
43 error e[35mpeere[39m e[1mvuee[22m@"e[1m>= 2.5 < 3e[22m" from e[1m@vue/composition-apie[22m@e[1m1.2.4e[22me[2me[22m
43 error e[2mnode_modules/@vue/composition-apie[22m
43 error   peerOptional e[1m@vue/composition-apie[22m@"e[1m^1.2.4e[22m" from e[1mpiniae[22m@e[1m2.0.0-rc.13e[22me[2me[22m
43 error   e[2mnode_modules/piniae[22m
43 error     e[1mpiniae[22m@"e[1m*e[22m" from the root project
43 error
43 error Fix the upstream dependency conflict, or retry
43 error this command with --force, or --legacy-peer-deps
43 error to accept an incorrect (and potentially broken) dependency resolution.
43 error
43 error See /home/.../.npm/eresolve-report.txt for a full report.
44 verbose exit 1

I’m using

  • Pop!_OS 21.04 (Ubuntu)
  • node v14.18.1
  • npm v7.5.2
  • Vue CLI v4.5.13

It might be worth to note that I installed Node/npm LTS (v14.x) via

I don’t know why but it’s possible to install Pinia via plugin

So running

vue add vue-cli-plugin-pinia

works for me …

Does someone know how to fix it without the need of the plugin?