question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importing nativewind in tailwind.config.js throws Babel error "Cannot use import statement outside a module"

See original GitHub issue

Describe 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:open
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
marklawlorcommented, Oct 31, 2022

If you are experiencing this issue, please test the next version via nativewind@next. Please see #308 for more information

0reactions
amritkcommented, Nov 12, 2022

Same 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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found