Cannot find module in node_modules folder (but file exist)

  laravel, typescript, vue.js

When i run yarn run watch (inside my laravel project root) it compiles with no errors. However if i edit a file afterwards it show an error in the terminal for every single .ts file in my resources folder. Typescript in .vue files has no issues.

The error i am getting (for each .ts file is:

TS2307: Cannot find module '!../../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js' or its corresponding type declarations.

This file does exist inside my node_module folder.

I have googled it an the only thing i found remotely close to my problem is this link:
https://github.com/vuejs/vue-loader/issues/634

But none of the suggested solution/workarounds there work for me.

This is my tsconfig

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "experimentalDecorators": true,
    },
    "include": [
        "resources/js/**/*"
    ],
    "exclude": [
        "vendor",
    ]
}

I suspect it is either a configuration issue or a version problem in ts-loader or vue-loader.

"ts-loader": "^8.2.0",
"typescript": "^4.3.2"
"vue-loader": "^15.7.0",

Keep in mind i have to use 8.2. in order for laravel-mix to be able to work with it. Also i use vue-class-components and vue-property-decator

Source: Laravel

Leave a Reply