6

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

3 Answers 3

5

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

Sign up to request clarification or add additional context in comments.

Comments

3

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

Comments

1

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.