john grad
john grad

Reputation: 141

This dependency was not found in node_modules dependency

I have a Vue.js project A which I want to reuse in another Vue.js project B.

They have pretty similar setup: Vue.js + Typescript

I try to import components from A to B. What I do:

  1. Add A project as git submodule to B
  2. Add npm dependency to A project*
  3. Import component from this npm dependency

This component uses some utils from the A project in this way:

import { func } from '@/utils/functions';

A project has specified paths option in tsconfig.json:

"paths": {
        "@/*": [
            "src/*"
        ]
    }

When I start the B app I get an error that says:

This dependency was not found:

* @/utils/functions

It seems like relative paths specified in this way (@/) is not resolved in node_modules.

So, how should I define the tsconfig.json in B project to resolve this dependency for my imported component? Or is there any other way to do what I described above (maybe something about webpack configs)?

Upvotes: 0

Views: 514

Answers (1)

jeremy castelli
jeremy castelli

Reputation: 1260

in webpack config try something like that

module.exports = {
    configureWebpack: {
        resolve: {
            alias: {
                '@': path.join(__dirname, 'src'),
            }
        },
    }
}

Upvotes: 2

Related Questions