Vue version 3 is encountering an issue with a module that does not have an exported member in the specified path of "../../node_modules/vue/dist/vue"

After I updated my npm packages, errors started popping up in some of the imports from the 'vue' module:

TS2305: Module '"../../node_modules/vue/dist/vue"' has no exported member 'X'

The X instances affected include nextTick, onMounted, ref, watch, and more. When trying to serve the project, Vue throws a compilation error. Interestingly, WebStorm recognizes the exports, suggests them, and displays types, but the error persists. Notably, computed and defineComponent exports work without issues.

Here's what I've attempted so far:

  • Reverting back to an older version of Vue - specifically "3.2.2" compared to the current "3.0.11". This temporarily resolves the type errors mentioned earlier, however, it causes the app to break completely with numerous 'TypeError: Object(...) is not a function' errors in the console and failure to render the app at all. Additionally, terminal warnings are introduced:
    "export 'X' (imported as '_X') was not found in 'vue'
    where X represents createElementBlock, createElementVNode, normalizeClass, and normalizeStyle.
  • Rolling back other dependencies did not resolve the issue despite several attempts.
  • Manually declaring the entire 'vue' module. While this method successfully removes the errors by declaring the 'vue' module exports in shims-vue.d.ts, it feels like a tedious workaround. Thus, I'm looking for a better solution if available.

List of all my dependencies:

"dependencies": {
   "@capacitor/android": "3.0.0",
   /* Rest of the dependency list remains unchanged */
 },
 "devDependencies": {
   "@capacitor/cli": "3.0.0",
   /* Rest of the devDependency list remains unchanged */
 }

Link to reproduce

Answer №1

After reading through various comments and trying different solutions, I found that upgrading TypeScript from version "3.x.x" to "4.3.5" solved my issue. It seems that other 4.x.x versions could also work, but I have not personally tested them yet. My theory is that the update caused a compatibility issue with a vue-related dependency in the previous version of TypeScript.

Answer №2

It appears that the named exports from the composition API are not accessible, indicating that the Vue 2 version is being used in a specific location where only default export is available. Despite having Vue 3 in the dependencies and both the lock file and node_modules being updated, it suggests that Vue 2 is a nested dependency of a direct dependency.

To address this issue, a thorough investigation should be conducted on the lock file. It is evident that

@vue/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="294a45400459455c4e4047045c47405d04434c5a5d691d071c07181a">[email protected]</a>
relies on vue-jest@3, which in turn depends on vue@2.

One potential solution may involve upgrading @vue/cli-plugin-unit-jest to the latest version, specifically next. The same approach could possibly be applied to other @vue/cli-* packages as they tend to have compatible versions.

Answer №3

To successfully run the script, the TypeScript version must be 4.3.5 or higher. Unfortunately, my project did not function properly with version 4.0.3.

Answer №4

Encountered a related problem while working with pnpm, the issue stemmed from the preserveSymLinks setting in the compilerOptions section of my tsconfig.json file. Changing it to false resolved the errors.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Strange occurrences observed while looping through an enum in TypeScript

Just now, I came across this issue while attempting to loop through an enum. Imagine you have the following: enum Gender { Male = 1, Female = 2 } If you write: for (let gender in Gender) { console.log(gender) } You will notice that it iter ...

Angular 8: Issue with PatchValue in Conjunction with ChangeDetector and UpdateValue

I am puzzled by the fact that PatchValue does not seem to work properly with FormBuilder. While it shows data when retrieving the value, it fails to set it in the FormBuilder. Does anyone have an idea why this might be happening? I am utilizing UpdateValue ...

Deploy the Angular standalone component numerous times across a single page using Bootstrap

Edit After receiving input from Andrew, I have decided to adjust my strategy: Replacing survey-angular with the survey-angular-ui package Implementing a widget approach similar to the one outlined in this example Developing a single module that encompass ...

Combining TypeScript and ReactJS with RequireJS: A guide to importing react-dom in TypeScript

I am currently working with TypeScript and React.js. Within Visual Studio 2015, I have set the project properties to use AMD as the module system for TypeScript build, meaning I am utilizing requirejs for importing modules. Within my main.tsx file, I am r ...

Modifying the value of an object key with Javascript

The information I am working with is structured as follows: obj = { pref: { language: 'English', } }; My goal is to update the language field to 'Spanish'. ...

Having trouble resolving a component from a component library while utilizing NPM link

My React application is set up with Create React App and a separate component library. I'm currently experimenting with using 'npm link' to test changes in the component library directly on my local machine. To achieve this, I first run &ap ...

Having issues with triggering click events using querySelector in Angular 2

Having trouble using querySelector with click() method in Angular it is causing a compilation error: 'click' is not recognized as a method on type 'Element' document.body.querySelector(".class").click(); ...

What methods are typically used for testing functions that return HTTP observables?

My TypeScript project needs to be deployed as a JS NPM package, and it includes http requests using rxjs ajax functions. I now want to write tests for these methods. One of the methods in question looks like this (simplified!): getAllUsers(): Observable& ...

The inability to publish npm libraries on the repository is a common issue faced when using Npm in conjunction with Nexus Repository Manager 3

I am currently facing a challenge uploading npm libraries to a Nexus Repository Manager 3.1 that is located on a server without internet access. To work around this issue, I performed an npm install on a separate computer to obtain the necessary libraries ...

Installing failed due to an error in the postinstall script of @angular/core version 9

I'm at the beginning of my coding journey and I am looking to set up a source code on my computer. node -v v12.16.1 npm -v 6.13.4 Could you assist me in resolving this issue that arises when I try to run the npm install command (on Windows 7 ...

V3: Ensuring Autocomplete Stays Focused and Clears Input on Keydown Enter

Is there a way to clear the v-autocomplete without exiting the autocomplete after the user presses enter? I came across a somewhat working solution for vuefiy 3 in an answer to a similar question on Stack Overflow. While it didn't completely solve my ...

Saving three different forms with just a single submission using Angular 10

Trying to simultaneously save 3 forms of an angular stepper, where the products (secondFormGroup) and values(thirdFormGroup) may contain multiple rows. The API model is structured as follows: { "product": [ { "description": ...

Having trouble adding a package right after creating a project with create-react-app

Just started learning react (only a day ago). Used create-react-app command line to set up an app. Here's what I did: create-react-app my-app npm start App was running smoothly at this point. Then, I proceeded with: npm install youtube-api-search n ...

The custom error page in NextJS is failing to display

In my custom pages/404.ts file, I have coded the following: export default function NotFound() { return <h1>404 - Page Not Found</h1> } Additionally, there is another page that displays a 404 error when the organization is null: import Error ...

Troubleshooting Angular 2 Component: Why is console.log not functioning in Typescript?

I'm fairly new to both Angular2 and typescript. Given that typescript is a superset of javascript, I assumed that functions like console.log would function as expected. Interestingly, console.log works perfectly in .ts files when placed outside a comp ...

Creating tests in JestJs for React components that utilize Context Provider and Hooks

As a newcomer to front-end development, I am currently working on authentication with Okta-React. To pass logged-in user information across multiple components, I'm utilizing React context with hooks. While this approach works well, I encountered an i ...

Unable to locate module: unable to resolve 'child_process' in '/home/fawad/pmc-frontend_master/node_modules/dialog'

When running npm run build, I encountered the following error: "module not found: cannot resolve 'child_process' in '/home/fawad/pmc-frontend_master/node_modules/dialog'". I tried installing child_process using both npm install child_pr ...

Receiving Server Emissions in Vue/Vuex with Websockets

In my Vue component, I was using socket.io-client for WebSocket communication. Now that I've added Vuex to the project, I declared a Websocket like this: Vue.use(new VueSocketIO({ debug: true, connection: 'http://192.168.0.38:5000', })) ...

What is the process for creating a method within a class?

Here is the current structure of my class: export class Patient { constructor(public id: number, public name: string, public location: string, public bedId: number, public severity: string, public trajectory: number, public vitalSigns: ...

I need to know how to create a patch request in Vue.js and simultaneously modify the marks input for specific individuals by using v-model

Hello there, I am currently developing a student assessment input form using vuejs, express, and mongoDB. The backend API is complete and functioning properly when tested with postman. Here is the code: // UPDATE MARKS router.patch('/:studentId' ...