[英]React & Babel: You may need an additional loader to handle the results of these loaders
Im working on a react app made with create-react-app
, and whenever I start the app I get this error:我正在开发一个使用
create-react-app
,每当我启动应用程序时,我都会收到此错误:
./node_modules/scrambles/dist/esm/scrambles.js 37:39
Module parse failed: Unexpected token (37:39)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|
| async function getWorker() {
> const url = outsideStrategy.url.esm ?? outsideStrategy.url.cjs;
| const workerInstantiator = outsideStrategy.workerInstantiator.esm ?? outsideStrategy.workerInstantiator.cjs;
| let worker;
Here are my dependencies in package.json
:这是我在
package.json
中的依赖项:
"dependencies": {
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"@types/node": "^15.3.0",
"bulma": "^0.9.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^4.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1",
"scrambles": "^0.1.13",
"typescript": "^4.2.4",
"web-vitals": "^1.1.2"
},
Im not knowledgeable at all when it comes to bable
, and based on the error, that seems to be a source of the issue.我对
bable
,并且基于错误,这似乎是问题的根源。 I have tried downgrading react-scripts
as another post directed, but I had no luck with that.我曾尝试按照另一篇文章的指示降级
react-scripts
,但我没有运气。 Any help is greatly appreciated;任何帮助是极大的赞赏; Ive been trying to fix this for hours.
几个小时以来,我一直试图解决这个问题。
It looks like this is a known issue with create react app and dependencies that use nullish coalescing.看起来这是创建反应应用程序和使用无效合并的依赖项的已知问题。 See this GitHub issue for more information https://github.com/facebook/create-react-app/issues/9468
有关更多信息,请参阅此 GitHub 问题https://github.com/facebook/create-react-app/issues/9468
One of the suggested fixes is to change your browserslist config in your package.json to this:建议的修复之一是将 package.json 中的 browserslist 配置更改为:
"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
],
That may fix it for you because it'll change how Babel is transpiling your code.这可能会为你解决这个问题,因为它会改变 Babel 编译你的代码的方式。 It looks like it's not transpiling any nullish coalescing because it's supported by the browserslist you're targeting.
看起来它没有转换任何无效的合并,因为它受到您所定位的浏览器列表的支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.