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

Viewed 3310

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

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

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

More detail packages

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

enter image description here

2 Answers

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...

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 ✅
  }
}
Related