The library "vue-property-decorator" (v10.X) is causing issues with resolving in Webpack despite being successfully installed

Encountered an error message

Module not found: Error: Can't resolve './decorators/Emit'
while attempting to import functionality from the library vue-property-decorator. The package is installed and accessible, ruling out a simple installation oversight.

https://i.stack.imgur.com/6v1Ux.png

Interestingly, IntelliJ IDEA does not display the files in the tree view, yet I can access them through the 'go to source' feature and by checking the native file system.

https://i.stack.imgur.com/HQu2X.png

The specific errors encountered include:

ERROR in ../node_modules/vue-property-decorator/lib/index.js 3:0-41
Module not found: Error: Can't resolve './decorators/Emit' in 'C:\Users\XXXX\Package\node_modules\vue-property-decorator\lib'
 @ ./index.ts 1:0-49 2:12-19

ERROR in ../node_modules/vue-property-decorator/lib/index.js 4:0-45
Module not found: Error: Can't resolve './decorators/Inject' in 'C:\Users\XXXX\Package\node_modules\vue-property-decorator\lib'
 @ ./index.ts 1:0-49 2:12-19

ERROR in ../node_modules/vue-property-decorator/lib/index.js 5:0-43
Module not found: Error: Can't resolve './decorators/Model' in 'C:\Users\XXXX\Package\node_modules\vue-property-decorator\lib'
 @ ./index.ts 1:0-49 2:12-19\

Typically, such errors point to TypeScript compiler settings like allowSyntheticDefaultImports or esModuleInterop, but in this case, they are Webpack-related. For reference, here is my TypeScript configuration:

{
  "compilerOptions": {

    "target": "ES2020",
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,

    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "experimentalDecorators": true,

    "baseUrl": "./",
    "paths": {}
  }
}

My Webpack configuration looks like this:

import Webpack from "webpack";
import Path from "path";
import { VueLoaderPlugin } from "vue-loader";


const webpackConfig: Webpack.Configuration = {

  context: Path.resolve(process.cwd(), "Source"),
  entry: "./index.ts",
  output: {
    filename: "index.js",
    path: Path.resolve(process.cwd(), "Distributable")
  },
  mode: "development",
  watch: true,

  module: {
    rules: [
      {
        test: /\.ts$/,
        loader: "ts-loader",
        options: {
          appendTsSuffixTo: [ /\.vue$/ ]
        }
      },
      {
        test: /\.vue$/,
        loader: "vue-loader"
      },
      {
        test: /\.pug$/u,
        oneOf: [
          {
            resourceQuery: /^\?vue/u,
            use: [ "pug-plain-loader" ]
          },
          {
            use: [
              {
                loader: "html-loader",
                options: {
                  minimize: { caseSensitive: true }
               }
             },
             "pug-html-loader"
           ]
         }
       ]
     }
   ]
 },

  resolve: {
    extensions: [ ".ts" ]
  },

  plugins: [
    new VueLoaderPlugin()
  ]
};


export default webpackConfig;

No issues were faced with vue-property-decorator for Vue 2.x, but adjustments are needed for version 10.x supporting Vue 3.x. Open to suggestions except using boilerplate setups via Vue-cli or Vite - focusing on manual setup with Webpack.

Answer №1

Make sure to include the .js extension in your Webpack configuration:

resolve: {
  extensions: [".js", ".ts"]
},

The .js extension is crucial in any Webpack configuration as all dependencies need to be compiled to JavaScript for Webpack to process them effectively.

I recently cloned your repository and encountered an error regarding a missing 'pug' package, which was resolved by installing it. The remaining errors seem to be related to 'noUnusedParameters: true' in your tsconfig.json file.

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

Issue with Vue router: Unable to retrieve API data after redirection

I am currently developing an application that utilizes JWT Login. I have implemented a check to see if the user is logged in when they visit the homepage ("/"), and then redirect them to the Dashboard: let routes = [ { path: '', component: L ...

What is the C sharp version of this code structure?

I'm curious to know what the C# syntax is for declaring a property like this: filters: { [arg: string]: string }; ...

Steps to insert a personalized attribute into a TypeScript interface

UPDATED EXPLANATION: I'm fairly new to TypeScript, so please bear with me if this question seems basic. I'm working with an existing library (ngx-logger) that I don't want to or can't modify. My goal is to create a service that generat ...

Images not showing in Vue.js

I have been working on setting up a carousel using bootstrap-vue. It is being generated dynamically through an array containing three objects with keys such as id, caption, text, and image path. The issue I am facing now is that while the caption and text ...

How to bind a dynamic image source in a Vue component

I need to dynamically bind the src of my image. This is my template: <template> <div class="item"> <div class="img"> <img v-bind:src="getImg" > </div> </div ...

Troubleshooting: Prettier Extension Compatibility Issue in VS Code with Create-React-App and Typescript Template

I'm currently in the process of setting up my application using the Create-React-App startup package with the TypeScript template. Everything goes smoothly during the initial installation. However, when I attempt to use the Prettier Code Formatter ext ...

The art of combining Angular 6 with CSS styling for dynamic

Can we dynamically set a value in an scss file from the ts component like demonstrated below? public display: "none" | "block"; ngOnInit(): void { this.display = "none"; } ::ng-deep #clear { display: {{display}} !imp ...

Can someone please explain how to prevent Prettier from automatically inserting a new line at the end of my JavaScript file in VS Code?

After installing Prettier and configuring it to format on save, I encountered an issue while running Firebase deploy: 172:6 error Newline not allowed at end of file eol-last I noticed that Prettier is adding a new line at the end when formatting ...

How can I emphasize the React Material UI TextField "Cell" within a React Material UI Table?

Currently, I am working on a project using React Material UI along with TypeScript. In one part of the application, there is a Material UI Table that includes a column of Material TextFields in each row. The goal is to highlight the entire table cell when ...

Vue Project Encounters Issues with router-link and router-view in the Boilerplate Setup

After using the command vue create to set up a new Vue project with Babel, TypeScript, Router, and Unit Testing, I proceeded to install axios via npm. With no additional modifications made, I attempted to run the application by navigating to the src direc ...

Vue custom headers not successfully added in request

While making a request using Axios, I encountered an issue when trying to add custom headers as required by the API. When including the custom headers, the response received is: CORS policy: Response to preflight request doesn't pass access control c ...

Utilizing Vue JS for applying multiple filters on a single array

I'm currently facing challenges in optimizing my code. I've successfully created dynamically generated objects from an array, implemented a search function, and had a working filter (just one) at some point. However, my attempt to chain the filte ...

Monitor changes in a dynamic child component using Angular fire and TypeScript only (no HTML)

Currently, I am developing a component using TypeScript and passing inputs to my child component from there. In the parent TypeScript file: this.childComponent = this.viewContainerRef.createComponent(this.data.body).instance; this.childComponent['chi ...

Guide on showing information from Firebase Database in Vuetify Datatable using VueJs

I am encountering an issue with my code. I am unable to display data in a Vuetify Datatable, even though I have enabled Read and Write permissions on my Firebase Database. Here is the code I am using for this functionality. Any feedback or suggestions woul ...

Tips for troubleshooting and resolving the npm ERR! code E404 issue in Vue.js when implementing a datepicker

I am a newcomer to Vue.js and I am currently exploring the use of a datepicker from However, upon importing the script for usage, I encountered the following message: 'VMdDateRangePicker' is declared but its value is never read.ts(6133) Cou ...

Proper utilization of react-hook-form in conjunction with TypeScript and material-ui to display error messages efficiently

Currently, I am using a combination of react-hook-form with typescript and material-ui. My goal is to pass the error message as a helperText to the TextField. I attempted to achieve this by utilizing helperText={errors.email?.message} however, TypeScript ...

Re-activate video playback after 30 seconds of user inactivity (using RxJs)

My intention is to provide a brief explanation of the functionality I am looking for. Essentially, when a video is playing, I want it to pause if a user clicks on it, allowing them to do something else. Then, after 30 seconds of idle time, I need the video ...

Is there a way to assign API data as inner HTML using Lit?

Need help setting inner html of html elements with a get request Any suggestions on how to achieve this? import { LitElement, html, css } from "lit"; import { customElement } from "lit/decorators.js"; import axios from "axios" ...

Vue's Post Request Triggering Data Changes

Encountering a challenge where the data does not update correctly when a new object is included in the array. The current process involves looping through an array of engagements associated with a client as shown below: <div class="row mx-2 px-2 justif ...

What is the best way to assign string values from an array in data() to the src attribute of an image element?

I've been working on a feature where the <div.box> element appears based on the user's input through a form. In this project, I'm using vue3 and v-for to iterate over an array 'images' that contains URL strings linking to ima ...