vision-camera-code-scanner
vision-camera-code-scanner copied to clipboard
globals is not a valid Plugin property
I am using this bable.config.js
module.exports = { presets: ['module:metro-react-native-babel-preset'], plugins: [ "react-native-reanimated/plugin", { globals: ["__scanCodes"] } ], };
==================Error======================
globals is not a valid Plugin property
- Maybe you meant to use "plugins": [ ["react-native-reanimated/plugin", { "globals": [ "__scanCodes" ] }] ] To be a valid plugin, its name and options should be wrapped in a pair of brackets
When I am trying to use this format "plugins": [ ["react-native-reanimated/plugin", { "globals": [ "__scanCodes" ] }] ]
it is throwing error Requiring module "node_modules/vision-camera-code-scanner/src/index.ts", which threw an exception: ReferenceError: __scanCodes is not defined .
*Only react-native-vision-camera is working fine but I need to scan bardcode.
✋ I got the same problem trying to install the plugin
✋ I got the same problem trying to install the plugin
Solved my issue:
module.exports = { presets: ['module:metro-react-native-babel-preset'], plugins: [ [ 'react-native-reanimated/plugin', { globals: ['__scanCodes'], }, ], ], };
@janodetzel, I already tried this but not working for me. module.exports = { presets: ['module:metro-react-native-babel-preset'], plugins: [ [ 'react-native-reanimated/plugin', { globals: ['__scanCodes'], }, ], ], };
In this case, it is showing me following error: Requiring module "node_modules/vision-camera-code-scanner/src/index.ts", which threw an exception: ReferenceError: __scanCodes is not defined .
I had the same error, when i tried to compile it under Windows. After switching to Linux (Manjaro) the error disappeared and compiling succeded.
I'm also getting this error, i'll update here if i find what fixes it.
https://github.com/mrousavy/react-native-vision-camera/issues/730#issuecomment-1013062721
the above linked fixed it for me. Pasting exactly what he had into my babel.config.js is what fixed it along with deleting my node_modules and reinstalling them, npm start -- --reset-cache inside the project folder, cd android, then ./gradlew clean, and finally npx react-native run-android
i reinstalled my project under windows, after a linux install was successfull, and it's working now. I think the error comes from some compiled files which were not deleted with the delete cache command.
mrousavy/react-native-vision-camera#730 (comment)
the above linked fixed it for me. Pasting exactly what he had into my babel.config.js is what fixed it along with deleting my node_modules and reinstalling them, npm start -- --reset-cache inside the project folder, cd android, then ./gradlew clean, and finally npx react-native run-android
Worked for me !
hand I got the same problem trying to install the plugin
Solved my issue:
module.exports = { presets: ['module:metro-react-native-babel-preset'], plugins: [ [ 'react-native-reanimated/plugin', { globals: ['__scanCodes'], }, ], ], };
work to me, thanks!
According to the official documentation of react-native-reanimated, if you use extra config for a plugin, then this last should be wrapped with brackets:
module.exports = {
presets: [
...
],
plugins: [
...
[
'react-native-reanimated/plugin', {
relativeSourceLocation: true,
globals: ['__scanCodes'],
},
]
],
};
Documentation link https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/