Open slhck opened 4 years ago
Same issue here, same exact setup. Will continue digging and report back if I find anything.
EDIT: Try changing metro.config.js
to the following:
module.exports = {
transformer: {
getTransformModulePath: () => {
return require.resolve('./transformer');
},
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
@slhck @Raymond-Cox any solution to this?
add babylon and babel-traverse as dev dependencies.
@mrcarjul After adding the dependencies, the above error is solved!!
But i get this:
Loading dependency graph, done. Loading dependency graph...Failed to construct transformer: { Error: Cannot find module 'metro/src/reactNativeTransformer' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object.getMetroTransformer (/home/naya/Documents/sabdakos/node_modules/react-native-obfuscating-transformer/dist/getMetroTransformer.js:19:16) at obfuscatingTransformer (/home/naya/Documents/sabdakos/node_modules/react-native-obfuscating-transformer/dist/obfuscatingTransformer.js:38:208) at Object.
(/home/naya/Documents/sabdakos/transformer.js:3:18) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) code: 'MODULE_NOT_FOUND' } error Cannot read property 'transformFile' of undefined. Run CLI with --verbose flag for more details. TypeError: Cannot read property 'transformFile' of undefined at /home/naya/Documents/sabdakos/node_modules/metro/src/Bundler.js:87:34 at Generator.next ( ) at asyncGeneratorStep (/home/naya/Documents/sabdakos/node_modules/metro/src/Bundler.js:14:24) at _next (/home/naya/Documents/sabdakos/node_modules/metro/src/Bundler.js:34:9)
Any solution to this?
@slhck @Raymond-Cox any solution to this?
What happened when you changed metro.config.js file to what I suggested?
@razorabhu1995
module.exports = obfuscatingTransformer({ / add this to your transformer.js file i think it will fix it / upstreamTransformer: require('metro-react-native-babel-transformer'),
@Raymond-Cox with your solution error is gone but nothing happened to source code it's not encrypted.
I think the contributors of this library must have a re iterate over how metro bundler work in react native >= 0.60
+1
@AustinZuniga tnx that solved the problem
@mrcarjul After adding the dependencies, the above error is solved!!
But i get this:
Loading dependency graph, done. Loading dependency graph...Failed to construct transformer: { Error: Cannot find module 'metro/src/reactNativeTransformer' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object.getMetroTransformer (/home/naya/Documents/sabdakos/node_modules/react-native-obfuscating-transformer/dist/getMetroTransformer.js:19:16) at obfuscatingTransformer (/home/naya/Documents/sabdakos/node_modules/react-native-obfuscating-transformer/dist/obfuscatingTransformer.js:38:208) at Object. (/home/naya/Documents/sabdakos/transformer.js:3:18) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) code: 'MODULE_NOT_FOUND' } error Cannot read property 'transformFile' of undefined. Run CLI with --verbose flag for more details. TypeError: Cannot read property 'transformFile' of undefined at /home/naya/Documents/sabdakos/node_modules/metro/src/Bundler.js:87:34 at Generator.next () at asyncGeneratorStep (/home/naya/Documents/sabdakos/node_modules/metro/src/Bundler.js:14:24) at _next (/home/naya/Documents/sabdakos/node_modules/metro/src/Bundler.js:34:9)
Any solution to this?
@razorabhu1995 Did you manage to resolve this issue? I too am getting the error Error: Cannot find module 'metro/src/reactNativeTransformer'
@razorabhu1995 so the fix for this has actually already been merged into master, however it has not been deployed to npm
. I manually implemented the changes within node_modules
- see https://github.com/javascript-obfuscator/react-native-obfuscating-transformer/pull/15.
yarn add babylon -dev
I am using this in a RN 0.61.5 project, and I've installed the project with:
When running
npx react-native start
, I get this error:After running
npm i babylon --save-dev
, I get:My
transformer.js
is:And my Metro Config:
I see that Babylon is part of the dependencies: https://github.com/javascript-obfuscator/react-native-obfuscating-transformer/blob/master/package.json#L14 – but then again, there seem to be duplicates?