Skip to content

files with .jsx extension give import error whereas .js works fine. #33100

@Alroyfernz

Description

@Alroyfernz

Description

While I tried to import my screen componets from ./screens which were in .jsx extension initially had some problem importing it.But when I changed the extension to .js was able to import them without any problem.

Version

0.67.2

Output of npx react-native info

System:
OS: Windows 10 10.0.22000
CPU: (8) x64 AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
Memory: 1001.20 MB / 5.88 GB
Binaries:
Node: 14.17.3 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.14.13 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 29, 30, 32
Build Tools: 29.0.2, 30.0.2, 32.0.0, 32.1.0
System Images: android-29 | Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Version 2021.1.0.0 AI-211.7628.21.2111.8092744
Visual Studio: Not Found
Languages:
Java: 15.0.2 - C:\Program Files\Common Files\Oracle\Java\javapath\javac.EXE
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.67.2 => 0.67.2
react-native-windows: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

Files with .jsx extension throw an import error saying:
error: Error: Unable to resolve module ./screens/OnBoarding1 from C:\Users\alroyfernz\Desktop\Programming\Bloom.bit\pharmacy_app\App.js:

Later digging into the solution I just tried to change the extension from .jsx to .js and it worked.

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

bugSC1

bug
bug3
bug4

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