Module parse failed: Unexpected character '#' (7:2) File was processed with these loaders:

1.1k Views Asked by At

Has anyone encountered something like this?

Background: About a week ago, the (React) project was working fine and everything was normal.

Around the same time, I started working on a new project, but this time using React Native. Both projects are on the same working machine but naturally in different folders. During the initial setup of the React Native project, I had to deal with a bunch of errors, and apparently, in one of those error resolutions, I either updated a package (probably unnecessarily) or installed a new one.

I returned to the old project only a couple of days later and found the below error. Therefore, I can't determine what exactly broke it.

Failed to compile.

./node_modules/ml-matrix/src/symmetricMatrix.js 7:2
Module parse failed: Unexpected character '#' (7:2)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| export class SymmetricMatrix extends AbstractMatrix {
|   /** @type {Matrix} */
>   #matrix;
|   get size() {
|     return this.#matrix.size;

What I've tried:

I tried npm clean cache, deleting the node_modules folder, and deleting the package-lock.json file, but it didn't help.

Using @babel/preset-env also doesn't work.

Rolling back to an old commit also didn't resolve the issues (even going back 5 commits).

The project was originally built using CRA (Create React App). There are no files such as .babelrc, babel.config.js, or webpack.config.js.

1

There are 1 best solutions below

0
On

The error originated from the latest commit of the ml-matrix library.Check the version of ml-matrix in your yarn.lock file and rollback to the previous version.This is worked for me.