Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: _typeof is not defined /w CRA 2.0 #335

Closed
Mcbeer opened this issue Oct 10, 2018 · 9 comments
Closed

ReferenceError: _typeof is not defined /w CRA 2.0 #335

Mcbeer opened this issue Oct 10, 2018 · 9 comments

Comments

@Mcbeer
Copy link

Mcbeer commented Oct 10, 2018

Using Create-React-App v2.0 i get the following error in the console, when loading Quagga. The webcam loads up fine, and displays an image, but it will not scan barcodes.

blob:http://localhost:3000/b34a09e5-04a0-495f-bcc5-91af1e544d8b:1472 Uncaught ReferenceError: _typeof is not defined

Below you can see a (maybe) more clear version of what i'm seeing.
screen shot 2018-10-10 at 15 35 50

@ctriantaf
Copy link

Same problem with CRA v1.3.3

@ericblade
Copy link
Collaborator

ericblade commented Oct 10, 2018

my gut reaction is that CRA is doing something weird here -- perhaps transpiling Quagga despite it already being transpiled by babel. .babelrc here contains "transform-es2015-typeof-symbol", which makes me suspicious that CRA is doing something incorrectly. FWIW, I'm using @enact tooling to handle my app, and have had no problems with it, but I am not an authority on transpiling tooling. I'm pretty certain that it's a configuration problem, I'm not sure if it's re-transpiling it, or exactly what, though.

@Mcbeer
Copy link
Author

Mcbeer commented Oct 11, 2018

@ericblade It was indeed CRA doing something they shouldn't have.

It appears updating to react-scripts 2.0.4 fixes this issue, as per:

facebook/create-react-app#5267

Thanks for your help, in guiding me to point my fingers elsewhere :-)

@Mcbeer Mcbeer closed this as completed Oct 11, 2018
@ericblade
Copy link
Collaborator

@clepto please see link above for any specific details, upgrade to CRA 2.0.4 or better, or downgrade to a version prior to when they added whatever they were doing to typeof. Thanks for the investigation, Mcbeer, glad I could point you in a better direction. :-D

@cedm
Copy link

cedm commented Apr 17, 2019

I'm getting the same error, but not using CRA.

I'm running a fairly basic Rails 5 with Webpack setup, and the _typeof is not defined error happens when I use the Quagga NPM package and load it via Webpack (import Quagga from 'quagga'). If I bypass Webpack and link to it directly via a <script scr="quagga.min.js"> tag (I manually downloaded the quagga.min.js file from Github), everything works fine.

I don't understand what the issue is...

@rkiller
Copy link

rkiller commented May 29, 2020

I'm seeing the exact same issue as @cedm . Any updates on this?

@ericblade
Copy link
Collaborator

I'm still not an expert in webpack, but my gut feel on it is that something needs to be configured to just import the package, and not process it. I think? this is what the "externals" configuration is for in webpack, but not certain. Quagga itself refers to lodash as external, and I think that is why?

@Sioomak
Copy link

Sioomak commented Mar 18, 2021

Same Quagga error here with webpack. Any update on a possible configuration solution?

@LimmaPaulus
Copy link

I managed to bypass this problem with the following import:

import Quagga from 'quagga/dist/quagga';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants