Skip to content

Unable to resolve module console from /node_modules/@testing-library/react-native/build/helpers/logger.js #1740

@caralin3

Description

@caralin3

Unable to resolve module console from /node_modules/@testing-library/react-native/build/helpers/logger.js

I am trying to build and run my app locally via react-native run-android, but the build is failing with the following from @testing-library/react-native/. When I remove the @testing-library/react-native/ library, I don't get this error, but I want to use this library for testing.

BUILD FAILED in 37s
error Failed to install the app.
error Unable to resolve module console from /node_modules/@testing-library/react-native/build/helpers/logger.js: console could not be found within the project or in these directories: node_modules/@testing-library/react-native/node_modules node_modules
  6 | exports.logger = void 0;  7 | var _chalk = _interopRequireDefault(require("chalk"));
> 8 | var nodeConsole = _interopRequireWildcard(require("console"));  | ^  9 | var _redent = _interopRequireDefault(require("redent"));  10 | var nodeUtil = _interopRequireWildcard(require("util"));  11 | function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }. FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':app:createBundleJsAndAssets'.
> Process 'command 'node'' finished with non-zero exit value 1 * Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org. BUILD FAILED in 37s.
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1

Here are the relevant libraries I have in my package.json:

"dependencies": {
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "^0.73.8",
}
...
"devDependencies": {
    "@testing-library/react-native": "^13.0.1",
    "eslint-plugin-testing-library": "^7.1.1",
    "react-test-renderer": "18.2.0",
    "setimmediate": "^1.0.5",
}

Any ideas on how to fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions