Skip to content

Webpack could not deduce aliases from TS / JS config file. #12168

Open
@laxsuryavanshi

Description

@laxsuryavanshi

Describe the bug

After setting up, and using path mappings in tsconfig.json file, webpack gives module resolution error.

Module not found: Error: Can't resolve '@module' in '/path/frontend/src/file'
 @ ./src/App.tsx 7:0-46 22:30-42
 @ ./src/index.tsx 7:0-24 11:33-36

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

Webpack resolve, alias
Typescript path mappings
Module not found: Error: Can't resolve '@module' in 'path/to/file'

Environment

Using yarn v1.22.17
Node: v14.17.6
OS: MacOS 12.2.1
CPU: Apple M1

Steps to reproduce

  1. yarn create react-app frontend --template typescript
  2. Add baseUrl and paths to compilerOptions in tsconfig.json file
  3. yarn start

Expected behavior

Webpack should get module aliases from tsconfig.json file.

Actual behavior

Webpack gives Module not found error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions