Binh Ho
Binh Ho

Reputation: 4934

Module '"vue"' has no exported member 'reactive'

I am using "vue": "^3.0.0" and trying to use some Reactivity in Depth from vue. But got the error

Module '"vue"' has no exported member 'reactive'
Module '"vue"' has no exported member 'ref'

Documentation here: https://v3.vuejs.org/guide/reactivity.html#what-is-reactivity

More detail on package.json

"vue-class-component": "^8.0.0-0",
"vue-property-decorator": "^9.1.2",
...
"@vue/compiler-sfc": "^3.0.0",

enter image description here

Upvotes: 6

Views: 6479

Answers (3)

blackgreen
blackgreen

Reputation: 44827

Using pnpm, I was able to fix this by adding two dependencies:

pnpm add @vue/runtime-core
pnpm add @vue/runtime-dom

Upvotes: 0

Edie Lemoine
Edie Lemoine

Reputation: 395

For whoever comes across this question, is using pnpm and running into this issue with all Vue exports, like:

Problems:
TS2305: Module '"vue"' has no exported member 'defineComponent'.
TS2305: Module '"vue"' has no exported member 'Component'.
TS2305: Module '"vue"' has no exported member 'Ref'.
TS2305: Module '"vue"' has no exported member 'ref'.

I noticed I had "preserveSymlinks": true in my tsconfig.json, removing it (or setting it to false) cleared the errors.

// tsconfig.json
{
  // ...
  "compilerOptions": {
    // ...
    "preserveSymlinks": false // no more errors ✅
  }
}

Upvotes: 3

Michal Levý
Michal Levý

Reputation: 37813

One of your dependencies is not compatible with Vue 3 - requiring Vue 2. So you have installed both versions.

You can try execute npm explain vue to find out which one is it...

Upvotes: 5

Related Questions