Skip to content

Import from path alias in RN 0.69.4 #34434

@AlirezaHadjar

Description

@AlirezaHadjar

Description

importing from path alias doesn't work in the react native after upgrading to v69.

Version

0.69.3

Output of npx react-native info

System:
OS: macOS 12.5
CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
Memory: 40.48 MB / 8.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.14.0 - /usr/local/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 8.3.1 - /usr/local/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
Android NDK: 22.1.7171670
IDEs:
Android Studio: 2021.1 AI-211.7628.21.2111.8193401
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
Languages:
Java: 11.0.12 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.0.0 => 18.0.0
react-native: 0.69.3 => 0.69.3
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

After upgrading react native version from 66 to 69, I'm facing this issue:
TypeError: Cannot read property 'component' of undefined
This component has been imported from the path alias like this:
import { component } from "@components";
but if I change the import approach and do it like this: import { component } from "./src/{ path to the component }";, the issue is gone.

Snack, code example, screenshot, or link to a repository

Screen Shot 2022-08-17 at 1 25 57 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Triage 🔍StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions