问题:
今天webpack在打包过程中使用copy-webpack-plugin插件的时候,报了以下错误:
HookWebpackError: Only file and data URLs are supported by the default ESM loader. Received protocol 'node:'at makeWebpackError (E:\vue\02-webpack\04-webpack_插件\node_modules\webpack\lib\HookWebpackError.js:48:9)at E:\vue\02-webpack\04-webpack_插件\node_modules\webpack\lib\Compilation.js:3055:12at eval (eval at create (E:\vue\02-webpack\04-webpack_插件\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:60:1)at E:\vue\02-webpack\04-webpack_插件\node_modules\webpack\lib\Compilation.js:508:26at E:\vue\02-webpack\04-webpack_插件\node_modules\copy-webpack-plugin\dist\index.js:485:13
-- inner error --at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:750:11)at Loader.resolve (internal/modules/esm/loader.js:85:40)at Loader.getModuleJob (internal/modules/esm/loader.js:229:28)at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:51:40)at link (internal/modules/esm/module_job.js:50:36)
caused by plugins in Compilation.hooks.processAssets
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. Received protocol 'node:'at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:750:11)at Loader.resolve (internal/modules/esm/loader.js:85:40)at Loader.getModuleJob (internal/modules/esm/loader.js:229:28)at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:51:40)at link (internal/modules/esm/module_job.js:50:36)
原因:版本问题
解决:降低版本,完美解决
npm i -D copy-webpack-plugin@9.*