Factsheet
» npm install @babel/preset-react
» npm install babel-preset-react
» npm install babel-preset-react-app
Input in react-validation lies under build folder. But from the error it seems that you didn't imported Input properly: SyntaxError: E:\Projects\personal\rental-application\node_modules\react-validation\src\components\input\index.js: Support for the experimental syntax 'jsx' isn't currently enabled (6:3):
Can you please check your import statement? It should be something like this:
import Input from "react-validation/build/input";
1st proposal
As it is suggested in this thread, run
bundle exec rails webpacker:install:react. It will add that bit to the babel.config.js automatically. You will not need to manually do something.
. . . . . .
2nd proposal
You should install @babel/preset-react as it is suggested in the error message.
Using npm:
npm install --save-dev @babel/preset-react
or using yarn:
yarn add @babel/preset-react --dev
See our website @babel/preset-react for more information. Ref: https://github.com/babel/babel/tree/master/packages/babel-preset-react
. . . . . .
3rd proposal
Alternatively, if the first proposal doesn't work, as it is suggested in this thread, you should update babel.config.js, so it will work. So update the file as it is suggested:
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
['@babel/preset-react', {targets: {node: 'current'}}] // add this
]
};
Running the below command solved my issue
npm install --save-dev @babel/plugin-proposal-private-property-in-object
use --save-dev to install it under devDependencies
2024 update:
The package @babel/plugin-proposal-private-property-in-object is deprecated.
Use
npm install --save-dev @babel/plugin-transform-private-property-in-objectinstead.Reference the package in your
.eslintrc, e.g.
{
"extends": ["@babel/plugin-transform-private-property-in-object", "next/core-web-vitals"]
}
Thanks to all, eventually that's what solved my problem:
npm install --save-dev @babel/plugin-proposal-private-property-in-object --legacy-peer-deps
» npm install @react-native/babel-preset
If this appears in VSCode with the fullstack approach (front and back as subfolders within your workspace), adjust eslint extensions configurations for your current workspace in .vscode/settings.json as following:
"eslint.workingDirectories": [
"./back",
"./front"
]
That solved this issue in my case.
Maybe it'll help someone, I just had a simillar problem which I solved.
I happened to have VSCode opened in a fullstack project where front and back were sepparate folders. When I opened VSCode only in the front folder this error faded away.
I guess a solution would be to make a shared node_modules folder or setup a workspace from front and back folders, I went with the 2nd option.