Webpack unable to compile js in already working node package

197 Views Asked by At

I'm trying to make some style changes to a node package I have installed using patch-package, and in order to do so I have to use webpack to compile the code in the src/ directory to get new code in dist/. When I run npx webpack I get the following error:

ERROR in ./src/index.js 189:12
Module parse failed: Unexpected token (189:12)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     render() {
|         return (
>             <div>

This node package worked fine out of the box, I remind you. I'm not sure what I'm missing here. The package doesn't come with any config file other than the default. Here's what's in there:

rules: [
      {
        test: /\.js$/,
        include: path.resolve(__dirname, 'src'),
        exclude: /(node_modules|bower_components|build)/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        }
      },

Thanks in advance!

Edit: removing node_modules & package-lock and reinstalling does not solve the issue

1

There are 1 best solutions below

2
On

clean your node_modules and reinstall the packages might help.