简体   繁体   English

React 应用程序因子编译和 webpack 错误而中断

[英]React app breaks with child compilation and webpack errors

I just finished the ReactJS.org tutorial and it was functional.我刚刚完成了 ReactJS.org 教程,它很实用。 Then I added a bunch of comments to explain each block of code, closed down the local server, and went home.然后我加了一堆注释解释每个代码块,关闭本地服务器,回家。 When I re-opened it to start tweaking it and trying advanced options, it broke, with several errors (webpack, eslint, child compilation failed...).当我重新打开它开始调整它并尝试高级选项时,它坏了,出现了几个错误(webpack、eslint、子编译失败......)。 The only thing that changed was a VS Code update.唯一改变的是 VS Code 更新。

The main error seems to be related to webpack, but I don't have a webpack config file, and I'm not using it to my knowledge.主要错误似乎与 webpack 有关,但我没有 webpack 配置文件,据我所知,我没有使用它。 I used create-react-app to build the app, and deleted the files in the src/ directory to start from scratch like the tutorial says to do.我使用create-react-app来构建应用程序,并删除了src/目录中的文件以从头开始,就像教程所说的那样。

Errors: (see image)错误:(见图)

  • When doing npm start , it says 1 ERROR in child compilations... in the terminal当做npm start ,它说1 ERROR in child compilations...在终端
  • Must use import to load ES module...必须使用 import 来加载 ES 模块...
  • Child compilation failed...子编译失败...

Troubleshooting:故障排除:

  • I removed and re-inserted ESLint config options in package.json我在 package.json 中删除并重新插入了 ESLint 配置选项
  • I tried npm uninstall eslint我试过npm uninstall eslint
  • Did a git checkout of the previous commit (the finished tutorial) which was functional, but it's broken now对上一个提交(完成的教程)进行了git checkout出,该提交是可用的,但现在已损坏
  • Also did an npm ls for reference (see images)还做了一个npm ls供参考(见图)

错误屏幕 网页错误 npm-ls

I have reproduced this problem, but my problem is that I created a project based on create-react-app in the V16.* version of Node, but I ran it with the V12.* version of Node.我重现了这个问题,但是我的问题是我在V16.*版本的Node中创建了一个基于create-react-app的项目,但是我用V12.*版本的Node运行它。 So when I re-run the 16.* version it will work, hopefully that will help you因此,当我重新运行 16.* 版本时,它会起作用,希望对您有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM