Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

"Unable to resolve path to module" error in VSCode for React Native Expo application

$
0
0

I'm developing a react native app in Expo and have recently received the following error messages in VSCode: "Unable to resolve path to module"

The error message is not displayed during relative imports or node module imports. However, all other imports show the error message.

What's interesting is that 1) VSCode's "Quick Fix" generates these imports, 2) right-clicking "Go to Definition" successfully locates the file, and 3) the imports actually work. Despite this, the error message "Unable to resolve path to module" persists.

Here's my tsconfig.json file.

{"extends": "expo/tsconfig.base","compilerOptions": {"strict": true,"moduleResolution": "node","preserveConstEnums": true,"noImplicitAny": true,"esModuleInterop": true,"resolveJsonModule": true,"jsx": "react-native","experimentalDecorators": true,"emitDecoratorMetadata": true,"skipLibCheck": true,"lib": ["ES2021"],"baseUrl": ".","paths": {"*": ["./src/*"],    },"rootDirs": ["./", "./src/"]  },"ts-node": {"require": ["tsconfig-paths/register"]  },"include": ["src/**/*.ts", "index.js"],"exclude": ["node_modules", "aws"]}

Here's my directoryProject/src//store/actionstsconfig.jsonpackage.jsonnode_modulesindex.js

Example of import with the issue described above.

For a file defined as Project/src/store/actions/actions.ts

import { MakeRequest, REQUEST_TYPE } from 'store/fetch'; shows error message (other import based on tsconfig)

import { MakeRequest, REQUEST_TYPE } from '../fetch'; succeeds (relative import)


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>