繁体   English   中英

React: 编译失败 // webpack 问题

React: failed to compile // webpack problem

提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供   中文繁体   英文版本   中英对照 版本,有任何建议请联系yoyou2525@163.com。

我的项目无法再编译。 突然来了,不知道为什么。 它似乎与 webpack 有关。 也许我需要将 webpack 5 之前的版本降级,但我不知道如何在 React 中执行此操作。 我设法通过添加 resolve:fallback 将错误从 90 减少到 7,但我不知道如何处理其他人。 所以,现在我有这些错误:

Failed to compile.

Module not found: Error: Can't resolve 'child_process' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/jest-worker/build/workers'
WARNING in ./node_modules/jest-worker/build/WorkerPool.js 25:4-29
Module not found: Error: Can't resolve 'worker_threads' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/jest-worker/build'

WARNING in ./node_modules/jest-worker/build/base/BaseWorkerPool.js 122:19-46
Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/jest-worker/build/index.js 71:19-38
Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/jest-worker/build/workers/processChild.js 83:15-28
Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/jest-worker/build/workers/processChild.js 99:15-28
Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/loader-runner/lib/loadLoader.js 20:19-39
Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/terser-webpack-plugin/dist/minify.js 43:118-125
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

WARNING in ./node_modules/terser-webpack-plugin/dist/utils.js 519:18-51
Module not found: Error: Can't resolve 'uglify-js/package.json' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/terser-webpack-plugin/dist'

WARNING in ./node_modules/terser-webpack-plugin/dist/utils.js 596:18-51
Module not found: Error: Can't resolve '@swc/core/package.json' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/terser-webpack-plugin/dist'

WARNING in ./node_modules/terser-webpack-plugin/dist/utils.js 678:18-49
Module not found: Error: Can't resolve 'esbuild/package.json' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/terser-webpack-plugin/dist'

WARNING in ./node_modules/webpack/lib/EvalSourceMapDevToolPlugin.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/webpack/lib/[url]' file: Error: ENOENT: no such file or directory, open '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/webpack/lib/[url]'

WARNING in ./node_modules/webpack/lib/debug/ProfilingPlugin.js 29:14-34
Module not found: Error: Can't resolve 'inspector' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/webpack/lib/debug'

WARNING in ./node_modules/webpack/lib/serialization/ObjectMiddleware.js 679:18-34
Critical dependency: the request of a dependency is an expression

ERROR in ./node_modules/jest-worker/build/workers/ChildProcessWorker.js 9:15-39
Module not found: Error: Can't resolve 'child_process' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/jest-worker/build/workers'

ERROR in ./node_modules/jest-worker/build/workers/NodeThreadsWorker.js 29:15-40
Module not found: Error: Can't resolve 'worker_threads' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/jest-worker/build/workers'

ERROR in ./node_modules/jest-worker/build/workers/messageParent.js 23:8-33
Module not found: Error: Can't resolve 'worker_threads' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/jest-worker/build/workers'

ERROR in ./node_modules/terser-webpack-plugin/dist/utils.js 481:6-26
Module not found: Error: Can't resolve 'uglify-js' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/terser-webpack-plugin/dist'

ERROR in ./node_modules/terser-webpack-plugin/dist/utils.js 560:14-34
Module not found: Error: Can't resolve '@swc/core' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/terser-webpack-plugin/dist'

ERROR in ./node_modules/terser-webpack-plugin/dist/utils.js 639:18-36
Module not found: Error: Can't resolve 'esbuild' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/terser-webpack-plugin/dist'

ERROR in ./node_modules/webpack/lib/FileSystemInfo.js 11:19-36
Module not found: Error: Can't resolve 'module' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/webpack/lib'
Did you mean './module'?
Requests that should resolve in the current directory need to start with './'.
Requests that start with a name are treated as module requests and resolve within module directories (node_modules, /Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules).
If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.

webpack compiled with 7 errors and 13 warnings
问题暂未有回复.您可以查看右边的相关问题.
2 React扩展关键字Webpack无法编译

我是React的新手,当我编译下面的代码时会出错。 index.js: search_bar.js: 我从终端启动npm服务器,它在以下链接中给出了错误: 错误图片 ./src/components/search_bar.js中的错误模块构建失败:语法错误:意外 ...

3 Webpack无法编译React.js项目

我尝试使用webpack v2.2.1和web pack-dev-sever v2.4.1构建我的react模板项目。 当我运行“ webpack-dev-server --progress --hot --inline --colors”时,Web Pack报告“编译失败”。 我检查了 ...

4 无法编译,在Webpack上启动

我正在尝试将js,css和html与webpack集成到我的应用程序的前端部分。 我尝试在application.css文件中使用自定义的CSS,然后将其导入application.js中 。 它正在工作。 现在,我删除了CSS代码,并使用yarn安装了引导程序。 以下是我的pa ...

5 Angular webpack:无法编译

我正在学习Angular 5的官方教程。 我正在阅读服务: 章节服务这一章 现在,我在这一章中: 看它运行 浏览器刷新后,应用程序应该像以前一样运行,当您单击英雄名称时显示英雄列表和英雄详细信息视图。 我有这个错误: 实际上,我只是按照教程,我有这个错误 ...

8 Angular 4-Webpack:编译失败

当我尝试npm install一切似乎都可以正常工作,但是随后ng serve返回错误。 我几乎在尝试所有事情,但没有任何效果。 角度版本可能存在问题吗? 同一项目正在另一台计算机上工作。 有什么建议吗? ...

10 Webpack无法编译简单应用程序

我是Node和Webpack的新手。 我正在尝试设置一个简单的应用程序。 我无法使webpack成功编译该应用程序。 我已经为此苦苦挣扎了好几天。 我的应用程序位于https://github.com/Weste15/test-app.git 。 我收到一长串错误。 任何帮助将不胜感激。 谢谢! ...

2018-03-02 21:21:23 1 2605   webpack
暂无
暂无

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

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