webpack: Module not found: Error: Can't resolve (with relative path)

前端 未结 10 1956
长情又很酷
长情又很酷 2021-02-05 06:34

I have this structure of an app (node_modules dir excluded from this list):

├── actions.js
├── bundle.js
├── components
│   ├── App.js
│   ├── Foote         


        
相关标签:
10条回答
  • 2021-02-05 06:59

    changing templateUrl: '' to template: '' fixed it

    0 讨论(0)
  • 2021-02-05 07:05

    I met this problem with typescript but forgot to add ts and tsx suffix to resolve entry.

    module.exports = {
      ...
      resolve: {
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
      },
    };
    

    This does the job for me

    0 讨论(0)
  • 2021-02-05 07:07

    Had the same issue with module not found. Turns out I had a component import Picture from './Picture/Picture'; at the very bottom of all the imports. When I moved it below import React, { Component } from 'react';, it worked.

    0 讨论(0)
  • 2021-02-05 07:07

    Just add it to your config. Source: https://www.jumoel.com/2017/zero-to-webpack.html

    externals: [ nodeExternals() ]
    
    0 讨论(0)
  • 2021-02-05 07:11

    Your file structure says that folder name is Container with a capital C. But you are trying to import it by container with a lowercase c. You will need to change the import or the folder name because the paths are case sensitive.

    0 讨论(0)
  • 2021-02-05 07:15

    I had a different problem. some of my includes were set to 'app/src/xxx/yyy' instead of '../xxx/yyy'

    0 讨论(0)
提交回复
热议问题