vision-camera-code-scanner icon indicating copy to clipboard operation
vision-camera-code-scanner copied to clipboard

globals is not a valid Plugin property

Open msnainps opened this issue 3 years ago • 10 comments

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.

msnainps avatar Feb 15 '22 16:02 msnainps

✋ I got the same problem trying to install the plugin

janodetzel avatar Feb 17 '22 16:02 janodetzel

✋ 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 avatar Feb 17 '22 16:02 janodetzel

@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 .

msnainps avatar Feb 23 '22 08:02 msnainps

I had the same error, when i tried to compile it under Windows. After switching to Linux (Manjaro) the error disappeared and compiling succeded.

trashcoder avatar Mar 05 '22 15:03 trashcoder

I'm also getting this error, i'll update here if i find what fixes it.

IKyriazis avatar Mar 06 '22 20:03 IKyriazis

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

IKyriazis avatar Mar 06 '22 21:03 IKyriazis

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.

trashcoder avatar Mar 11 '22 06:03 trashcoder

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 !

Uhmoja avatar Apr 29 '22 13:04 Uhmoja

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!

Evaldoes avatar Dec 13 '22 20:12 Evaldoes

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/

mustapha-ghlissi avatar May 02 '23 16:05 mustapha-ghlissi