CRA error. Html Webpack Plugin: Error: Child compilation failed:
CRA error. Html Webpack Plugin: Error: Child compilation failed:
我使用 npx create-react-app app-name --template typescript
创建了一个默认的 React 应用程序,但我的应用程序无法运行。错误:
Html Webpack Plugin:
Error: Child compilation failed:
Module build failed (from ../../../#Node/authorization/6. crypto-converter/node_modules/html-webpack-pl ugin/lib/loader.js):
Error: Cannot find module 'C:\#Node\authorization. crypto-converter\node_modules\html-webpack-plugin\ lib\loader.js'
Require stack:
- C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\loadLoader.js
- C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunner.js
- C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\NormalModule.js
- C:\#Node\authorization. crypto-converter\node_modules\webpack-manifest-plugin\dist\index.js
- C:\#Node\authorization. crypto-converter\node_modules\react-scripts\config\webpack.config.js
- C:\#Node\authorization. crypto-converter\node_modules\react-scripts\scripts\start.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at loadLoader (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\loadLoader. js:19:17)
at iteratePitchingLoaders (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib \LoaderRunner.js:182:2)
at runLoaders (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunne r.js:397:2)
at NormalModule._doBuild (C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\Normal Module.js:812:3)
at NormalModule.build (C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\NormalMod ule.js:956:15)
at C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\Compilation.js:1367:12
ModuleBuildError: Module build failed (from ../../../#Node/authorization/6. crypto-converter/node_modul es/html-webpack-plugin/lib/loader.js):
Error: Cannot find module 'C:\#Node\authorization. crypto-converter\node_modules\html-webpack-plugin\ lib\loader.js'
Require stack:
- C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\loadLoader.js
- C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunner.js
- C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\NormalModule.js
- C:\#Node\authorization. crypto-converter\node_modules\webpack-manifest-plugin\dist\index.js
- C:\#Node\authorization. crypto-converter\node_modules\react-scripts\config\webpack.config.js
- C:\#Node\authorization. crypto-converter\node_modules\react-scripts\scripts\start.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at loadLoader (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\loadLoader. js:19:17)
at iteratePitchingLoaders (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib \LoaderRunner.js:182:2)
at runLoaders (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunne r.js:397:2)
at NormalModule._doBuild (C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\Normal Module.js:812:3)
at NormalModule.build (C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\NormalMod ule.js:956:15)
at C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\Compilation.js:1367:12
at processResult (C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\NormalModule.j s:751:19)
at C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\NormalModule.js:853:5
at C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunner.js:399:11
at C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunner.js:185:11
at loadLoader (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\loadLoader. js:33:11)
at iteratePitchingLoaders (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib \LoaderRunner.js:182:2)
at runLoaders (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunne r.js:397:2)
...`
在此之前我看到警告:
(node:2720) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:2720) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
我试过了:
- 创建新应用程序
- 在其他目录创建应用程序
- 删除node.js
- 安装 node.js 的其他版本(16.14.0、17.4.0、16.13.2 - 活动)
解决方法:安装react-scripts@4.0.3。如果您知道如何解决 react-script@5.0.0 的问题,请写信给我们。
我使用 npx create-react-app app-name --template typescript
创建了一个默认的 React 应用程序,但我的应用程序无法运行。错误:
Html Webpack Plugin:
Error: Child compilation failed:
Module build failed (from ../../../#Node/authorization/6. crypto-converter/node_modules/html-webpack-pl ugin/lib/loader.js):
Error: Cannot find module 'C:\#Node\authorization. crypto-converter\node_modules\html-webpack-plugin\ lib\loader.js'
Require stack:
- C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\loadLoader.js
- C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunner.js
- C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\NormalModule.js
- C:\#Node\authorization. crypto-converter\node_modules\webpack-manifest-plugin\dist\index.js
- C:\#Node\authorization. crypto-converter\node_modules\react-scripts\config\webpack.config.js
- C:\#Node\authorization. crypto-converter\node_modules\react-scripts\scripts\start.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at loadLoader (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\loadLoader. js:19:17)
at iteratePitchingLoaders (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib \LoaderRunner.js:182:2)
at runLoaders (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunne r.js:397:2)
at NormalModule._doBuild (C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\Normal Module.js:812:3)
at NormalModule.build (C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\NormalMod ule.js:956:15)
at C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\Compilation.js:1367:12
ModuleBuildError: Module build failed (from ../../../#Node/authorization/6. crypto-converter/node_modul es/html-webpack-plugin/lib/loader.js):
Error: Cannot find module 'C:\#Node\authorization. crypto-converter\node_modules\html-webpack-plugin\ lib\loader.js'
Require stack:
- C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\loadLoader.js
- C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunner.js
- C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\NormalModule.js
- C:\#Node\authorization. crypto-converter\node_modules\webpack-manifest-plugin\dist\index.js
- C:\#Node\authorization. crypto-converter\node_modules\react-scripts\config\webpack.config.js
- C:\#Node\authorization. crypto-converter\node_modules\react-scripts\scripts\start.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at loadLoader (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\loadLoader. js:19:17)
at iteratePitchingLoaders (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib \LoaderRunner.js:182:2)
at runLoaders (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunne r.js:397:2)
at NormalModule._doBuild (C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\Normal Module.js:812:3)
at NormalModule.build (C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\NormalMod ule.js:956:15)
at C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\Compilation.js:1367:12
at processResult (C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\NormalModule.j s:751:19)
at C:\#Node\authorization. crypto-converter\node_modules\webpack\lib\NormalModule.js:853:5
at C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunner.js:399:11
at C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunner.js:185:11
at loadLoader (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\loadLoader. js:33:11)
at iteratePitchingLoaders (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib \LoaderRunner.js:182:2)
at runLoaders (C:\#Node\authorization. crypto-converter\node_modules\loader-runner\lib\LoaderRunne r.js:397:2)
...`
在此之前我看到警告:
(node:2720) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:2720) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
我试过了:
- 创建新应用程序
- 在其他目录创建应用程序
- 删除node.js
- 安装 node.js 的其他版本(16.14.0、17.4.0、16.13.2 - 活动)
解决方法:安装react-scripts@4.0.3。如果您知道如何解决 react-script@5.0.0 的问题,请写信给我们。