Skip to content

Absolute imports don't work, need to place src/ in front of each path #10594

Description

@kevinmamaqi

Describe the bug

When using absolute imports as in the documentations they won't work unless I use src/componentes/... This happens since I updated to the latest npm and node versions.

Did you try recovering your dependencies?

I have done all the steps. Using npm version 7.5.5

Which terms did you search for in User Guide?

Absolut imports react

Environment

Environment Info:

current version of create-react-app: 4.0.3
running from /Users/kevinmamaqi/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app

System:
   OS: macOS 11.2.1
   CPU: (8) arm64 Apple M1
 Binaries:
   Node: 15.9.0 - /opt/homebrew/bin/node
   Yarn: Not Found
   npm: 7.5.5 - /opt/homebrew/bin/npm
 Browsers:
   Chrome: 88.0.4324.182
   Edge: Not Found
   Firefox: Not Found
   Safari: 14.0.3
 npmPackages:
   react: ^16.13.1 => 16.14.0 
   react-dom: ^16.13.1 => 16.14.0 
   react-scripts: ^2.0.5 => 2.1.8 
 npmGlobalPackages:
   create-react-app: Not Found

Steps to reproduce

(Write your steps here:)

  1. Install latest versions of node + npm
  2. Install react app with create-react-app
  3. add jsconfig.json as indicated in the documentation
  4. Import a component from ./src/components/... as 'component/myComponent/;
  5. It throws an error that Can't resolve path.

Expected behavior

Import the components.

Actual behavior

https://ibb.co/GTV620Y

Reproducible demo

Can't upload a demo to reproduce.

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