[React Native] Can't find variable: __dirname
See original GitHub issueI simply added
import useSWR from 'swr'
then error occurred Can’t find variable: __dirname
__dirname
is on compiled dist code, but React Native doesn’t support _dirname
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
[React Native] Can't find variable: __dirname #137 - GitHub
I am facing a similar issue but when importing it from import useSWR from '@zeit/swr' it works fine @n3tr Thanks for maintaining this....
Read more >React Native ReferenceError Can't find variable - Stack Overflow
I am trying to use the tag instead of and it this gives no reference found error. Code : import React, {Component} from...
Read more >ReferenceError: Can't find variable: useAuth - React Native
Assuming that you are working on the “DoneWithIt” app for react Native: you should have a module here: /app/auth/useAuth.js.
Read more >Alternatives to __dirname in Node.js with ES modules
The new __dirname and __filename variables created in the code above work just like in CommonJS — if you pass them around, they'll...
Read more >Using Next.js with Expo for Web
Next.js is a React framework that provides simple page-based routing as well as server-side rendering. To use Next.js with Expo for web we...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The current cache structure needs some refactoring to support async cache mechanisms. And after that, we will be able to support custom cache APIs like AsyncStorage.
The
__dirname
variable is located innode_modules/swr/dist/index.js
I need to importswr/esm
to bypass it