question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importing children components. Module not found: Error: Can't resolve

See original GitHub issue

To start, I’ve been successful with all of vue-styleguidist up to this point. The moment I imported a component into another component I’m met with Module not found.

Dependencies:

"typescript": "~4.5.2",
"vue-loader": "^15.0.0",
"vue": "2.6.14",
"vue-property-decorator": "^9.1.2",
"vue-style-loader": "^4.1.3",
"vue-styleguidist": "^4.45.1",
"ts-loader": "^9.3.1",
"webpack": "^5.0.0",

Full error:

Module not found: Error: Can't resolve '../ui-comp-chip' in '/correct/path/to/component'
[tsl] ERROR in /correct/path/to/ui-comp/UiComp.ts(8,26)
      TS2307: Cannot find module '../ui-comp-child/UiCompChild.vue' or its corresponding type declaration

Below is the file directory with corresponding files that may paint a picture of what I am doing. For the sake of brevity, I’ve removed any information that is unnecessary to solve the problem.

lib/
├─ ui-comp/
│  ├─ index.ts
│  ├─ UiComp.ts
│  ├─ UIComp.Vue
├─ ui-comp-child/
│  ├─ index.ts
│  ├─ UiCompChild.ts
│  ├─ UiCompChild.vue

// ui-comp/UiComp.ts

import { Vue, Component, Prop } from 'vue-property-decorator';

import UiCompChild from '../ui-comp-child';

@Component({
  components: {
      UiChipAction,
  },
})
export default class UiComp extends Vue {}
// ui-comp/UiComp.vue

<template>
  <span>
      <ui-comp-child></ui-comp-child>
  </span>
</template>

<script lang="ts" src="./UiComp.ts"></script>
// ui-comp/index.ts

import UiComp from './UiComp.vue';
export default UiComp;
// styleguide.config.js
module.exports = {
  ...
  components: [
    path.join(process.cwd(), 'path/to/files/', '**/*.vue')
  ],
  webpackConfig() {
    return {
      module: {
        rules: [
          {
            test: /\.ts$/,
            loader: 'ts-loader',
            options: { appendTsSuffixTo: [/\.vue$/] }
          },
          {
            test: /\.vue$/,
            loader: 'vue-loader'
          },
          {
            test: /\.scss$/,
            use: [
              'vue-style-loader',
              'css-loader',
              'sass-loader'
            ]
          }
        ]
      },
      plugins: [ new VueLoaderPlugin() ],
    }
  }
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
elevatebartcommented, Jun 26, 2022

hello @whosdustin,

The investigation is going well:

  • The error you get points to the missing shims-vue.d.ts. Perhaps this file is in your project but not in scope of the tsconfig.json.
  • Once that’s taken care of, I get another error: The loader does not resolve ../ui-child to ../ui-child/index.ts. I think it has to do with the tsconfig. Let me check.
0reactions
whosdustincommented, Jun 26, 2022

Thank you so much! It’s always the simplest things that one can miss. I appreciate you taking the time to help me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error: Can't resolve child component
It compiles well but I get a runtime error that the child component is not resolved. BookStore.tsx (parent component) import { SearchBooks, ...
Read more >
NextJS Module not found: Can't resolve 'components/layout'
Hello. I was want to try gts in my project. After 'npx gts init' when I try to start my project I getting...
Read more >
Troubleshooting | React Navigation
Troubleshooting. This section attempts to outline issues that users frequently encounter when first getting accustomed to using React Navigation.
Read more >
NgModule FAQ - Angular
An NgModule can even export a module that it doesn't import. What should I not export?link. Don't export the following: Private components, directives,...
Read more >
FAQs - styled-components
If you think that the issue is in duplicated styled-components module somewhere in your dependencies, there are several ways to check this. You...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found