Whenever I attempt to install vue-class-component
, vue-class-component
, or vue-property-decorator
, I encounter the following error message:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e7829f868a978b82a7d7c9d7c9d7">[email protected]</a>
npm ERR! Found: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fb8d8e9ebbc8d5cfd5ce">[email protected]</a>
npm ERR! node_modules/vue
npm ERR! vue@"^3.3.11" from the root project
npm ERR! peer vue@"*" from <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c9bfbcace4b9bba6b9acbbbdb0e4adacaaa6bba8bda6bb89f0e7f8e7fb">[email protected]</a>
npm ERR! node_modules/vue-property-decorator
npm ERR! vue-property-decorator@"*" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^2.0.0" from <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="631516064e000f0210104e000c0e130c0d060d1723544d514d55">[email protected]</a>
npm ERR! node_modules/vue-class-component
npm ERR! peer vue-class-component@"*" from <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="92e4e7f7bfe2e0fde2f7e0e6ebbff6f7f1fde0f3e6fde0d2abbca3bca0">[email protected]</a>
npm ERR! node_modules/vue-property-decorator
npm ERR! vue-property-decorator@"*" 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.
This is perplexing: It mentions I have
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6315160623504d574d56">[email protected]</a>
, but the packages necessitate at least versions 3.3.11
and 2.0.0
, which renders them unattainable. However, doesn't "at least" imply they should work?
<template>
<p :title="computedText">{{ computedText }}</p>
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
@Component
export default class Example extends Vue {
private text = 'Hello World!'
public get computedText(): string { return this.text }
}
</script>
I also attempted using defineComponent
, which imports successfully. However, I encountered issues accessing the definitions within the template:
<template>
<p :title="computedText">{{ computedText }}</p>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
defineComponent({
data() {
return {
text: 'Hello World!'
}
},
computed: {
computedText(): string { return this.text }
}
})
</script>
Overall, I am quite perplexed about the correct approach to utilizing TypeScript with Vue.