create-react-app开玩笑遇到意外令牌{ [英] create-react-app jest encountered unexpected token {
问题描述
我正在使用create-react-app
开发带有QR扫描仪的React应用.
我添加了模块react-qr-reader
,该模块又使用了模块webrtc-adapter
.
I'm developing a React app with a QR-scanner in it with create-react-app
.
I've added the module react-qr-reader
which in turn uses the modules webrtc-adapter
.
一切正常,直到我运行yarn test
.然后它向我显示此错误:
It all works great, until I run yarn test
. Then it shows me this error:
我已经弹出了项目,因此可以使用transformIgnorePatterns
并将node_modules/webrtc-adapter
添加到数组中,但这仍然会导致相同的错误.
I've already ejected the project so I can use transformIgnorePatterns
and added node_modules/webrtc-adapter
to the array, but that still results in the same error.
有人可以帮我吗?
推荐答案
如果您不想从Create-React-App弹出,则可以在package.json中使用CLI来覆盖"transformIgnorePatterns".
If you don't want to eject from Create-React-App you can use the CLI in your package.json to override 'transformIgnorePatterns'.
参考- https://github.com/facebook/create-react-app/issues/2537#issuecomment-390341713
"scripts": {
"test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!your-module-name)/\"",
},
这篇关于create-react-app开玩笑遇到意外令牌{的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!