brainhubeu / react-carousel

A pure extendable React carousel, powered by Brainhub (craftsmen who ❤️ JS)

Home Page:https://brainhub.eu/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Module parse failed: Unexpected token on react-carousel.js

dasilvaluis opened this issue · comments

Describe the bug
I got this error when running a webpack build, which finds react-carousel.js in the dependencies.
React-carousel is a dependency of a repo that is being used in my project. It is not being imported into my code.

It is a React project with JS (no typescript). It has a standard webpack config, using babel-loader, but of course ignoring node_modules.

Strangely I have another project that has also react-carousel in it's dependencies which doesn't crash. It also does not crash in a fresh CRA installation.

Error:

Failed to compile.

./node_modules/@brainhubeu/react-carousel/lib/react-carousel.js
Module parse failed: Unexpected token (2:53548)
You may need an appropriate loader to handle this file type.

image

Babel version: 8.2.2
Webpack rule:

  {
      test: /\.jsx?$/,
      exclude: /(node_modules|vendor)/,
      loaders: 'babel-loader',
  }

Environment
It is an error coming from webpack.

npx envinfo --system --binaries --browsers --npmPackages '@brainhubeu/*'

  System:
    OS: Linux 5.11 Pop!_OS 21.04
    CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
    Memory: 900.87 MB / 15.29 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 14.15.5 - ~/.nvm/versions/node/v14.15.5/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v14.15.5/bin/yarn
    npm: 7.20.2 - ~/.nvm/versions/node/v14.15.5/bin/npm
  Browsers:
    Chrome: 92.0.4515.159
    Firefox: 91.0.1

Any clue what it might be?

FYI it got fixed after I upgraded babel, from v6 to v7