The write method of high-level component decorator is used in react project, and then the project reports an error. The information is as follows:
Support for the experimental syntax ‘decorators-legacy’ isn’t currently enabled
Solution:
1. Install Babel plugin transform decorators legacy
yarn add babel-plugin-transform-decorators-legacy
2. Modify the configuration file, package Add the following code to JSON:
"plugins": [ ["@babel/plugin-proposal-decorators", { "legacy": true }]],
Package There is no Babel configuration in JSON, which needs to be executed
yarn eject
Display the configuration of react script that is not displayed in package JSON
If the console reports an error after execution, the solution is to submit the local modification and execute
git add git commit -m ''
Then execute the yarn eject
3. Install Babel plugin transform decorators legacy
4. Modify package Babel in JSON
"babel": { "plugins": [ ["@babel/plugin-proposal-decorators", { "legacy": true }] ], "presets": [ "react-app" ]}
Similar Posts:
- [Solved] Mobx error: Support for the experimental syntax ‘decorators-legacy’ isn’t currently enab
- React uses antd to import error messages on demand
- Solve the problem of JS using JSX syntax to report errors in vite react project
- Support for the experimental syntax ‘classProperties’ isn’t currently enabled
- error An unexpected error occurred: “EPERM: operation not permitted, scandir ‘E:\\aPritice\\JDe\\e
- [Solved] React project NPM run error: npm ERR! errno 1
- npm run build : No such file or directory [How to Solve]
- How to Use Yarn instead of NPM
- Nuxt module build failed error report
- [Solved] Vue/cli install element error: Error: cannot find module ‘Babel plugin component’