title: How to fix module not found error in webpack.config.js file?
body: <p>Depending on the build target, I need to import and use components in different folders. The folder structure I am envisioning is as follows:</p>
  <pre><code>src
  ㄴ targetA
     ㄴ components
        ㄴ Comp
  ㄴ targetB
     ㄴ components
        ㄴ Comp
  </code></pre>
  <p>And I want to use it by changing only the build target without having to change the source code where comp is used.</p>
  <pre><code>import React from 'react';
  import Comp from 'components/Comp'; &lt;-- should not be changed per build target
  
  function App() {
    return (
      &lt;div&gt;
        &lt;Comp /&gt;
      &lt;/div&gt;
    );
  }
  
  export default App;
  </code></pre>
  <p>So, I set jsconfig.json and webpack.config.js like this:</p>
  <pre><code>jsconfig.json
  ---
  {
      &quot;compilerOptions&quot;: {
        &quot;baseUrl&quot;: &quot;.&quot;,
        &quot;paths&quot;: {
          &quot;components/*&quot;: [&quot;src/targetA/components/*&quot;]
        }
      }
  }
  
  webpack.config.js
  ---
  var path = require(&quot;path&quot;);
  
  module.exports = {
      resolve: {
          alias: {
              components: path.resolve(__dirname, &quot;./src/targetA/components/&quot;),
          }
      },
  }
  </code></pre>
  <p>When I enter &quot;npm start&quot; command in the terminal, the following error occurs. Please advise on how to fix it</p>
  <pre><code>Failed to compile.
  
  Module not found: Error: Can't resolve 'components/Comp' in '/Users/sckyj/Documents/dev/_one_front/src'
  assets by path static/js/*.js 1.47 MiB
    asset static/js/bundle.js 1.46 MiB [emitted] (name: main) 1 related asset
    asset static/js/node_modules_web-vitals_dist_web-vitals_js.chunk.js 6.92 KiB [emitted] 1 related asset
  asset index.html 1.67 KiB [emitted]
  asset asset-manifest.json 458 bytes [emitted]
  runtime modules 31.3 KiB 15 modules
  modules by path ./node_modules/ 1.35 MiB 99 modules
  modules by path ./src/ 8.8 KiB
    modules by path ./src/*.js 4.71 KiB
      ./src/index.js 1.79 KiB [built] [code generated]
      ./src/App.js 1.52 KiB [built] [code generated]
      ./src/reportWebVitals.js 1.39 KiB [built] [code generated]
    modules by path ./src/*.css 4.1 KiB
      ./src/index.css 2.72 KiB [built] [code generated]
      ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-loader/dist/cjs.js!./src/index.css 1.37 KiB [built] [code generated]
  
  ERROR in ./src/App.js 5:0-35
  Module not found: Error: Can't resolve 'components/Comp' in '/Users/sckyj/Documents/dev/_one_front/src'
  resolve 'components/Comp' in '/Users/sckyj/Documents/dev/_one_front/src'
    Parsed request is a module
    using description file: /Users/sckyj/Documents/dev/_one_front/package.json (relative path: ./src)
      Field 'browser' doesn't contain a valid alias configuration
      resolve as module
        /Users/sckyj/Documents/dev/_one_front/src/node_modules doesn't exist or is not a directory
        looking for modules in /Users/sckyj/Documents/dev/_one_front/node_modules
          /Users/sckyj/Documents/dev/_one_front/node_modules/components doesn't exist
        /Users/sckyj/Documents/dev/node_modules doesn't exist or is not a directory
        /Users/sckyj/Documents/node_modules doesn't exist or is not a directory
        /Users/sckyj/node_modules doesn't exist or is not a directory
        /Users/node_modules doesn't exist or is not a directory
        /node_modules doesn't exist or is not a directory
        looking for modules in /Users/sckyj/Documents/dev/_one_front/node_modules
          /Users/sckyj/Documents/dev/_one_front/node_modules/components doesn't exist
   @ ./src/index.js 7:0-24 11:33-36
  
  webpack 5.69.1 compiled with 1 error in 2757 ms
  </code></pre>