支持实验性语法“jsx”;从 Babel 6 升级到 Babel 7 时当前未启用
我正在尝试将React-Text面具
库升级到Babel 7
和React 17
。
为此我分叉: https://github.com/text-mask/text-mask/text-mask/text-mask
在这里: https://github.com/github.com/tlg-265/ react-text蒙版-17
然后我尝试通过以下命令升级babel:
$ npx babel-upgrade --write
您可以通过此操作轻松安装它:
$ git clone https://github.com/tlg-265/react-text-mask-react-17
$ cd react-text-mask-react-17
$ npm i
我的问题是:当我运行它时:
$ npm run react:dev
我遇到了这个错误:
Support for the experimental syntax 'jsx' isn't currently enabled
您可以在这里看到:
ERROR in ./react/example/index.js
Module build failed: SyntaxError: C:\react-text-mask-react-17\react\example\index.js: Support for the experimental syntax 'jsx' isn't currently enabled (6:3):
4 |
5 | ReactDOM.render(
> 6 | <App/>,
| ^
7 | document.querySelector('#content')
8 | )
9 |
Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing.
at instantiate (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:72:32)
at constructor (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:358:12)
at Parser.raise (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:3334:19)
at Parser.expectOnePlugin (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:3391:18)
at Parser.parseExprAtom (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:12969:18)
at Parser.parseExprSubscripts (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:12539:23)
at Parser.parseUpdate (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:12518:21)
at Parser.parseMaybeUnary (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:12489:23)
at Parser.parseMaybeUnaryOrPrivate (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:12283:61)
at Parser.parseExprOps (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:12290:23)
@ multi main
webpack: Failed to compile.
关于如何使其起作用的任何想法?
我的系统如下:
$ node -v
v12.16.1
$ npm -v
6.14.8
谢谢!
I'm trying to upgrade the react-text-mask
library to Babel 7
and React 17
.
For that I forked: https://github.com/text-mask/text-mask
here: https://github.com/tlg-265/react-text-mask-react-17
and then I tried to upgrade Babel with the following command:
$ npx babel-upgrade --write
You can easily install it by doing this:
$ git clone https://github.com/tlg-265/react-text-mask-react-17
$ cd react-text-mask-react-17
$ npm i
My problem is: When I run it with:
$ npm run react:dev
I get this error:
Support for the experimental syntax 'jsx' isn't currently enabled
as you can see here:
ERROR in ./react/example/index.js
Module build failed: SyntaxError: C:\react-text-mask-react-17\react\example\index.js: Support for the experimental syntax 'jsx' isn't currently enabled (6:3):
4 |
5 | ReactDOM.render(
> 6 | <App/>,
| ^
7 | document.querySelector('#content')
8 | )
9 |
Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing.
at instantiate (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:72:32)
at constructor (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:358:12)
at Parser.raise (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:3334:19)
at Parser.expectOnePlugin (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:3391:18)
at Parser.parseExprAtom (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:12969:18)
at Parser.parseExprSubscripts (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:12539:23)
at Parser.parseUpdate (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:12518:21)
at Parser.parseMaybeUnary (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:12489:23)
at Parser.parseMaybeUnaryOrPrivate (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:12283:61)
at Parser.parseExprOps (C:\react-text-mask-react-17\node_modules\@babel\parser\lib\index.js:12290:23)
@ multi main
webpack: Failed to compile.
Any idea on how to make it work?
My system is as follows:
$ node -v
v12.16.1
$ npm -v
6.14.8
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论