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

Developing a webpack configuration involving two distinct setups yet utilizing identical plugins

Currently, I am tackling a project based on vue.js where I need to develop two separate SPAs - one for the admin dashboard and another for the public side. My goal is to manage these projects separately but work on them simultaneously. It would be convenie ...

Having trouble with NPM install on Windows 10? It seems to be having issues cloning the git

I have a Git repository that I clone during npm installation. The Package.json file contains the Git URL. Everything works perfectly on my Win7 setup, but I am facing an issue on Win10. I'm not sure what I'm missing here. Package.json: { "name": ...

Is it possible to efficiently structure intricate JSON data onto interfaces in TypeScript with the incorporation of observables?

I am currently working on creating a simple web news reader that relies heavily on the Google News API (). I have set up all the necessary services, models, etc. However, I am having difficulty mapping the data onto specific interfaces. The Google API retu ...

Having trouble installing the React app through the terminal

I've encountered an issue while trying to install a react app using the terminal. Each time I attempt, it gives me an error stating that node is not recognized as an internal batch file. Oddly enough, when I run node --version, it shows v12.8.3. http ...

The 'wrapper' property is not present in the 'ClassNameMap<never>' type in Typescript

Hey there, I've been encountering a puzzling issue in my .tsx file where it's claiming that the wrapper doesn't exist. My project involves Material UI and Typescript, and I'm relatively new to working with Typescript as well as transiti ...

Comparing the functions of useMemo and the combination of useEffect with useState

Is there a benefit in utilizing the useMemo hook instead of using a combination of useEffect and useState for a complex function call? Here are two custom hooks that seem to function similarly, with the only difference being that useMemo initially returns ...

What is the process for sending a POST request from a plain JavaScript application?

I've developed a stand-alone webpage named index.html that includes a basic form with an input field. Every time I attempt to submit the form by clicking the button, I intend to send a POST request to my server. Unfortunately, the browser keeps displa ...

What is the proper method for typing unidentified exports that are to be used in TypeScript through named imports?

Currently, I am developing an NPM package that takes the process.env, transforms it, and then exports the transformed environment for easier usage. The module is structured like this: const transformedEnv = transform(process.env) module.exports = transf ...

Error: Property 'config' cannot be accessed because it is null

Upon transferring my Angular project from my local computer to a Linux server, I attempted to launch the project using ng serve but encountered an issue where it opened a new file in the console editor instead. After some investigation, I tried running np ...

Enhance the performance of page loading and implement a consistent spinner feature to ensure smooth transitions for users in Next.js version 13

I am currently working on a project using Next.js 13, and I am encountering issues with slow loading times and an unstable spinner when navigating between pages. Specifically, when transitioning from the home page to the /example page, the experience is n ...

Is there a way to assign the chosen option from a dropdown list to an input field in Vue 3?

I am working with a list that is returned from an API request. I have a text input field where I can search for items in the list, and the results are displayed dynamically as I type. My goal is to be able to select an option from the list and display the ...

Utilize the fetch function within a React functional component

I have been experimenting with different methods to fetch data only once before rendering, but I am encountering some challenges: It is not possible to call dispatch in componentDidMount as there is a restriction that it can only be done in Functional c ...

Ways to trigger the keyup function on a textbox for each dynamically generated form in Angular8

When dynamically generating a form, I bind the calculateBCT function to a textbox like this: <input matInput type="text" (keyup)="calculateBCT($event)" formControlName="avgBCT">, and display the result in another textbox ...

Using Angular 7 to set the value of an object returned by an observable to a variable

I encountered an issue while trying to assign the return value from a service to a component. ngOnInit() { this.getInspectionData(); } getInspectionData() { this.auctionService.getInspectionResult(`df570718-018a-47d8-97a2-f943a9786536`) ...

Transforming an Image URL into base64 format using Angular

I'm currently facing difficulty when attempting to convert a specified image URL into base64. In my scenario, I have a string that represents the image's path. var imgUrl = `./assets/logoEmpresas/${empresa.logoUrl}` Is there a way to directly co ...

A Typescript object that matches types and eventually returns a string when called upon

In the process of overengineering a type that can match either a string or an object whose valueOf() function, when evaluated recursively, ultimately returns a string. type Stringable = string | StringableObject; interface StringableObject { valueOf() ...

Asynchronous update of array elements - lack of firing watch events

I have recently developed a component that showcases previews of blog articles. This particular component includes pagination functionality, where selecting a new page triggers the refreshment of the article previews array. The list of articles is obtained ...

Tips for executing several JavaScript files using the Node.js command line?

I am looking to launch 4 scripts using Node.js. myapp -script1.js -script2.js -script3.js -app.js -package.json .... .... I attempted to run them with the following commands: node script1.js && node script2.js && node scrip ...

Can node.js be used to manipulate GIF images?

I'm currently using jimp for image manipulation as shown in the code snippet below. Is there any alternative library or tool that can be used to manipulate GIFs? var jimp = require('jimp'); jimp.read('images.png').then(function ( ...

Passing properties from the parent component to the child component in Vue3JS using TypeScript

Today marks my inaugural experience with VueJS, as we delve into a class project utilizing TypeScript. The task at hand is to transfer the attributes of the tabsData variable from the parent component (the view) to the child (the view component). Allow me ...