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.

TypeError: Cannot read property 'transformFile' of undefined

See original GitHub issue

Versions:

“react-native”: “0.59.10”, “react-native-obfuscating-transformer”: “^1.0.0”,

Files:

metro.config.js:

module.exports = {
    transformer: {
        babelTransformerPath: require.resolve("./transformer"),
        getTransformOptions: async () => ({
            transform: {
                experimentalImportSupport: false,
                inlineRequires: false,
            },
        }),
    },
};

transformer.js:

const obfuscatingTransformer = require('react-native-obfuscating-transformer')

module.exports = obfuscatingTransformer({})

Error I am getting:

Loading dependency graph, done.
Loading dependency graph...error Cannot read property 'transformFile' of undefined
debug TypeError: Cannot read property 'transformFile' of undefined
    at /home/chris/Documents/JSObfuscation/ObfuscationTest/node_modules/metro/src/Bundler.js:83:34
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/home/chris/Documents/JSObfuscation/ObfuscationTest/node_modules/metro/src/Bundler.js:14:24)
    at _next (/home/chris/Documents/JSObfuscation/ObfuscationTest/node_modules/metro/src/Bundler.js:34:9)

Repo

Simplest repo I could make that reproduces this error:

https://github.com/ExoMemphiz/ObfuscationTest/

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

11reactions
anhdevitcommented, May 14, 2020

I find the solution when using with react-native 0.61 This is my metro.config.js My problem disappear when I change babelTransformerPath: require.resolve(“./transformer”) to getTransformModulePath: () => { return require.resolve(‘./transformer’); },

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
    getTransformModulePath: () => {
      return require.resolve('./transformer');
    },
  },
};
0reactions
timorsscommented, Dec 8, 2021

npm i babylon --save-dev

Read more comments on GitHub >

github_iconTop Results From Across the Web

error: bundling failed: TypeError: Cannot read property ...
This is an old thread but I wanted to contribute as it is one of the first threads that appears in Google when...
Read more >
Cannot read properties of undefined (reading 'transformFile')
To solve the TypeError: Cannot read properties of undefined (reading 'transformFile'), update your `react-native` version to the latest.
Read more >
error: bundling failed: TypeError: Cannot read property ...
I got this error when trying to build my react native app after doing installs of node and npm. My machine was running...
Read more >
Error referencing code I can't find? Bundler.js - Reddit
Metro has encountered an error: Cannot read properties of undefined (reading 'transformFile'): /Users/[my name]/Desktop/[project ...
Read more >
failed to construct transformer react native - You.com
Metro has encountered an error: Cannot read property 'transformFile' of undefined: Web/Rayrok/apps/the-bible/node_modules/metro/src/Bundler.js (95:34) ...
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