Importing nativewind in tailwind.config.js throws Babel error "Cannot use import statement outside a module"
See original GitHub issueDescribe the bug
I want to customize font sizes to scale with the pixel ratio and followed the instructions at https://www.nativewind.dev/customization/theme. But adding the line const { fontScale } = require('nativewind');
results in a Babel build error Cannot use import statement outside a module
I’ve looked around but don’t see an obvious way to fix this but seems like something nativewind expects to work?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
SyntaxError: Cannot use import statement outside a module
To use TypeScript imports with Node.js, I installed the below packages. ... Then we'll create a .babelrc file for configuring Babel:
Read more >v3 - nativewind@next · Issue #308 - GitHub
Importing nativewind in tailwind.config.js throws Babel error "Cannot use import statement outside a module" #282.
Read more >How to fix "cannot use import statement outside a module"
This error occurs for one reason: you're trying to use import and you're not inside an ES module. It can happen in a...
Read more >Babel | NativeWind
The default babel configuration will both compile the Tailwind CSS styles and transform any component with the className attributed into a styled version....
Read more >Cannot use import statement outside a module - Medium
there is a good way to use import in NodeJS project without any error and it is babel , with babel we can...
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
If you are experiencing this issue, please test the
next
version vianativewind@next
. Please see #308 for more informationSame issue here, I tried the @next version as well.nvm got it working here: https://github.com/amritk/nativewind-expo-next/tree/next
Just had to remove
import { styled } from "nativewind";
when using babel