node-yahoo-finance2 icon indicating copy to clipboard operation
node-yahoo-finance2 copied to clipboard

Module parse failed: Unexpected token (161:57) (in CRA apps)

Open aneeshpanoli opened this issue 3 years ago • 4 comments

Bug Report

  • Module parse failed: Unexpected token (161:57)
  • You may need an additional loader to handle the result of these loaders.

Describe the bug

  • React compile error after installing the library

Minimal Reproduction

  • fresh install yarn add yahoo-finance2

Environment

Browser or Node: Node Node version (if applicable): v15.6.0 Npm version: 7.4.0 Library version (e.g. 1.10.1): 1.14.4

Additional Context

error

ReactJS | ./node_modules/yahoo-finance2/dist/esm/src/lib/validateAndCoerceTypes.js 161:57 ReactJS | Module parse failed: Unexpected token (161:57) ReactJS | File was processed with these loaders: ReactJS | * ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js ReactJS | You may need an additional loader to handle the result of these loaders. ReactJS | | /* istanbul ignore next */ ReactJS | | ReactJS | > const logObj = typeof process !== "undefined" && process?.stdout?.isTTY ? obj => console.dir(obj, { ReactJS | | depth: 4, ReactJS | | colors: true

aneeshpanoli avatar Aug 30 '21 20:08 aneeshpanoli

I have same issue when using Vue.js. I guess babel help this problem but I don't know how exactly.

daep93 avatar Sep 20 '21 06:09 daep93

I had a similar failure with vanilla Create React App. It's due to this issue (lack of support for nullish coalescing operator), and this fix works (for me).

pviotti avatar Oct 06 '21 18:10 pviotti

Hey all, thanks for the report and helpful links! I've been away but am back now, and have a simple fix in mind for this which I hope to implement this week or early next. Watch this space :) And thanks for your patience until now.

gadicc avatar Oct 12 '21 12:10 gadicc

Hey all (cc: @musiice). Please try the latest version, it works around this CRA issue by compiling down to ES2019 instead of ES2020. Please do report back.

gadicc avatar Oct 13 '21 07:10 gadicc