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.

Syntax error: pragma and pragmaFrag cannot be set when runtime is automatic.

See original GitHub issue

I started having this error since updating Gatsby to the most recent version and updating React to v17.

Syntax error: pragma and pragmaFrag cannot be set when runtime is automatic.

edit: The same issue now exists with the latest version of React react@16.14.0, right now the only fix is to go back to react@16.13.1 and react-dom@16.13.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:16
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

229reactions
dcastilcommented, Oct 26, 2020

Just adding here in case anyone sees this error message after upgrading a project to create-react-app v4:

Theme UI currently only supports the classic JSX runtime. Until emotion is upgraded to support the automatic runtime and Theme UI can be upgraded, add the comment /** @jsxRuntime classic */ to all files using the sx prop. This should fix the issue.

/** @jsxRuntime classic */
/** @jsx jsx */
import { jsx } from 'theme-ui';

You can also disable the automatic runtime globally instead by setting the environment variable DISABLE_NEW_JSX_TRANSFORM=true, e.g. in your .env file.

6reactions
JosephThomasVasquezcommented, Feb 26, 2021

Just adding here in case anyone sees this error message after upgrading a project to create-react-app v4:

Theme UI currently only supports the classic JSX runtime. Until emotion is upgraded to support the automatic runtime and Theme UI can be upgraded, add the comment /** @jsxRuntime classic */ to all files using the sx prop. This should fix the issue.

/** @jsxRuntime classic */
/** @jsx jsx */
import { jsx } from 'theme-ui';

You can also disable the automatic runtime globally instead by setting the environment variable DISABLE_NEW_JSX_TRANSFORM=true, e.g. in your .env file.

Confirming it works with dependencies:

"@theme-ui/presets": "^0.3.5",
   "next": "^10.0.7",
   "react": "^17.0.1",
   "react-dom": "^17.0.1",
   "theme-ui": "^0.3.5"
Read more comments on GitHub >

github_iconTop Results From Across the Web

Emotion CSS Prop and Nextjs new JSX runtime - error
Emotion CSS Prop and Nextjs new JSX runtime - error: pragma and pragmaFrag cannot be set when runtime is automatic.
Read more >
How to solve Pragma and pragmafrag can not be set while ...
How to solve Pragma and pragmafrag can not be set while runtime is automatic error ... What is a pragma? A pragma is...
Read more >
Error pragma and pragmaFrag cannot be set when runtime is ...
Hi team, @alexaspalato :wave: When i try to run npx frontity dev i get this error ` Error: .
Read more >
Error: x pragma cannot be set when runtime is automatic
If you are using Theme UI and you upgraded a react app or next.js app and you encounter an Error : pragma cannot...
Read more >
Pragma and pragmaFrag cannot be set when runtime is ...
How to solve pragma and pragmaFrag cannot be set when runtime is automatic when using theme ui in react.
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 Hashnode Post

No results found