Replies: 2 comments
|
A few things to check:
{
"parserOptions": {
"ecmaVersion": 2021
},
"env": {
"es2021": true
}
}
3.If you're using create-react-app, ensure you're on the latest react-scripts version, as older ESLint configurations may not recognize newer globals.
If the problem only occurs during npm run build, please share:
Your react-scripts version
Your Node.js version
Any custom ESLint configuration (.eslintrc or eslintConfig in package.json) |
|
This is most likely an ESLint configuration issue rather than a React or JavaScript runtime issue.
You can try adding the appropriate ECMAScript environment to your ESLint configuration. For example, in {
"env": {
"es2021": true,
"browser": true
}
}Or, if you're using an ESLint configuration where {
"globals": {
"WeakRef": "readonly"
}
}Also make sure your ESLint version/parser supports the ECMAScript version that introduced If you're using Create React App's default ESLint configuration and cannot modify the config directly, you may need to update the relevant
|
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I use create-react-app to create the app for me, and I have create some js file that use the WeakRef class in my react app.
When I run npm start command, it is running fine and able to compile.
However, when I run npm run build for the project. the eslint compiler failed to compile with error message WeakRef is not defined
Anyone encounter this behavior?
All reactions