create-react-app开玩笑遇到意外令牌{ [英] create-react-app jest encountered unexpected token {

查看:90
本文介绍了create-react-app开玩笑遇到意外令牌{的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆