[next-js] setImmediate is not defined
See original GitHub issueš Bug Report
Environment
Expo CLI 3.18.6 environment info:
System:
OS: macOS 10.15.2
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.13.1 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.12.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Xcode: 11.3/11C29 - /usr/bin/xcodebuild
npmPackages:
expo: ~37.0.3 => 37.0.7
react: ~16.9.0 => 16.9.0
react-native: https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz => 0.61.4
npmGlobalPackages:
expo-cli: 3.18.6
expo + next.js app (SDK 37)
Steps to Reproduce
Create a next.js project with expo, import react-native-reanimated
, use it in a component, and youāll see Error was not caught ReferenceError: setImmediate is not defined. in the browser console errors.
This also might be related to expo-web-browser
being imported. I havenāt dug too deep, but I found the solution and will put it at the bottom of this issue.
Expected Behavior
App works.
Actual Behavior
App throws error:

Error was not caught ReferenceError: setImmediate is not defined
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Jest Test Error: browserType.launch: setImmediate is not ...
I just added the polyfill.js in my test class : import 'core-js'; after that setImmediate was defined again and works now as intended....
Read more >Window.setImmediate() - Web APIs - MDN Web Docs
This method is used to break up long running operations and run a callback function immediately after the browser has completed other operationsĀ ......
Read more >Using Next.js with Expo for Web
Fixes setImmediate is not defined error. A lot of libraries in the React ecosystem use the setImmediate() API (like react-native-reanimated ), which Next.js...
Read more >react global is not defined | The AI Search Engine You Control
The solution is to either remove this piece of configuration (so React will be bundled with your javascript) or load the React framework...
Read more >setimmediate examples - CodeSandbox
Learn how to use setimmediate by viewing and forking setimmediate example apps on CodeSandbox. ... nextjs-testing Ā· sangwa7/to-do-list-app.
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
Solution
Polyfill
setImmediate
, which is used byreact-native-reanimated
.In
pages/_app.tsx
, at the top of the file:Hereās my
pages/_app.tsx
file, for reference:I figured Iād post this for anyone who finds themselves here. I bet Iāll also run into this again someday, so this is for future me as well.
Try this:
In
pages/_app.tsx