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.

Unable to resolve module promise/setimmediate/es6-extensions

See original GitHub issue

Environment

How do you use Sentry? Sentry SaaS (sentry.io)

Which SDK and version? @sentry/react-native@3.3.3 (iOS on react-native@0.67, Hermes enabled)

Steps to Reproduce

  1. Install the react-native SDK
  2. Attempt to import it, and receive an error about being unable to resolve module promises
  3. Clear all modules & pods, reset metro cache to be sure, and retry

Actual Result

error: Error: Unable to resolve module promise/setimmediate/es6-extensions from /Volumes/Dev/Users/harjot/projects/ShabadOS-mobile/node_modules/@sentry/react-native/dist/js/integrations/reactnativeerrorhandlers.js: promise/setimmediate/es6-extensions could not be found within the project or in these directories:
  node_modules

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
  46 |         const { polyfillGlobal, } = require("react-native/Libraries/Utilities/PolyfillFunctions");
  47 |         // Below, we follow the exact way React Native initializes its promise library, and we globally replace it.
> 48 |         const Promise = require("promise/setimmediate/es6-extensions");
     |                                  ^
  49 |         // As of RN 0.67 only done and finally are used
  50 |         require("promise/setimmediate/done");
  51 |         require("promise/setimmediate/finally");
    at ModuleResolver.resolveDependency (/Volumes/Dev/Users/harjot/projects/ShabadOS-mobile/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:129:15)
    at DependencyGraph.resolveDependency (/Volumes/Dev/Users/harjot/projects/ShabadOS-mobile/node_modules/metro/src/node-haste/DependencyGraph.js:288:43)
    at Object.resolve (/Volumes/Dev/Users/harjot/projects/ShabadOS-mobile/node_modules/metro/src/lib/transformHelpers.js:129:24)
    at resolve (/Volumes/Dev/Users/harjot/projects/ShabadOS-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33)
    at /Volumes/Dev/Users/harjot/projects/ShabadOS-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (/Volumes/Dev/Users/harjot/projects/ShabadOS-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33)
    at processModule (/Volumes/Dev/Users/harjot/projects/ShabadOS-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31)
    at async addDependency (/Volumes/Dev/Users/harjot/projects/ShabadOS-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:230:18)
    at async Promise.all (index 3)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
matt-oakescommented, Jul 15, 2022

The issue seems to be that because only the react-native module lists this as a dependency, it is stored in the node_modules/react-native/node_modules/promise path. This will not be searched by Metro for this require.

Adding promise to the projects depenencies has the effect of moving the promise module to node_modules/promise, which is one of the paths that is searched.

The correct fix is for promise to be defined as a dependency of @sentry/react-native which should then correctly place the promise module in node_modules root.

Personally I would reopen this and fix the underlying issue as you shouldn’t be requiring any modules that are not defined in your dependencies explicitly.

0reactions
marandanetocommented, Mar 30, 2022

Closing it since it’s apparently an environmental issue. I can’t reproduce on a brand new app and installing promise fixed the issue anyway.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Can't resolve 'promise/lib/es6-extensions.js' and ...
Try this npm install promise --save-dev. Make sure you included --save-dev. Still does not work? remove/delete the node_modules folder and ...
Read more >
How to use the promise/setimmediate/rejection-tracking ... - Snyk
To help you get started, we've selected a few promise/setimmediate/rejection-tracking.enable examples, based on popular ways it is used in public projects.
Read more >
promise - npm
This is a simple implementation of Promises. It is a super set of ES6 Promises designed to have readable, performant code and to...
Read more >
Configuring Jest
The function should either return a path to the module that should be resolved or throw an error if the module can't be...
Read more >
How to fix 'Module not found: Can't resolve 'http' in ... - YouTube
Basically, just change 'react-scripts' to 4.0.2 in your package.json and run `npm install` again :D Follow me on Twitter: ...
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