分析报错原因 ERROR in ./node_modules/worker-farm/lib/fork.js Module not found: Error: Can't resolve 'child_process' in 'D:\PRO_NEW\webpack-4\node_modules\worker-farm\lib' @ ./node_modules/worker-farm/lib/fork.js 3:21-45 @ ./node_modules/worker-farm/lib/farm.js @ ./node_modules/worker-farm/lib/index.js @ ./node_modules/terser-webpack-plugin/dist/TaskRunner.js @ ./node_modules/terser-webpack-plugin/dist/index.js @ ./node_modules/terser-webpack-plugin/dist/cjs.js @ (webpack)/lib/WebpackOptionsDefaulter.js @ (webpack)/lib/webpack.js @ ./build/webpack.prod.js
时间: 2023-09-27 17:07:52 浏览: 324
这个报错是因为在 worker-farm 库中的 fork.js 文件中,引用了 child_process 模块,但是在当前环境中找不到该模块导致的。这个问题可能是由于你的项目缺少了该模块,或者是该模块被错误地安装了。你可以通过检查你的项目中是否安装了 child_process 模块,或重新安装该模块来解决这个问题。此外,也可以检查你的环境变量是否正确设置。
相关问题
These dependencies were not found: * canvas in ./node_modules/pdfh5/js/pdf.js * dommatrix/dist/dommatrix.js in ./node_modules/pdfh5/js/pdf.js, ./node_modules/pdfh5/js/pdf.worker.js * web-streams-polyfill/dist/ponyfill.js in ./node_modules/pdfh5/js/pdf.js, ./node_modules/pdfh5/js/pdf.worker.js
It seems that some dependencies required by PDFH5 are missing. To resolve these dependencies, you can follow these steps:
1. Install missing dependencies: Run the following command in your project's root folder to install the missing dependencies:
```shell
npm install canvas dommatrix web-streams-polyfill
```
This will install the required packages (`canvas`, `dommatrix`, and `web-streams-polyfill`) and add them to your project's `node_modules` folder.
2. Import the dependencies: In the file `pdf.js` located in `node_modules/pdfh5/js/`, add the following import statements at the top of the file:
```javascript
import 'canvas';
import 'dommatrix/dist/dommatrix.js';
import 'web-streams-polyfill/dist/ponyfill.js';
```
Similarly, in the file `pdf.worker.js` located in `node_modules/pdfh5/js/`, add the same import statements at the top of the file.
3. Save the changes and rebuild: After adding the import statements, save the files and rebuild your project. Depending on your build system (Webpack, Rollup, etc.), you might need to run a command like `npm run build` or `npm run dev` to rebuild your project with the updated dependencies.
By following these steps, you should be able to resolve the missing dependencies for PDFH5.
Compiled with problems:X ERROR in ./node_modules/pdfjs-dist/es5/build/pdf.worker.js (./node_modules/vue-pdf/node_modules/worker-loader/dist/cjs.js!./node_modules/pdfjs-dist/es5/build/pdf.worker.js) Module build failed (from ./node_modules/vue-pdf/node_modules/worker-loader/dist/cjs.js): Error: MainTemplate.hooks.hotBootstrap has been removed (use your own RuntimeModule instead) at Object.tap (D:\newtest\node_modules\webpack\lib\MainTemplate.js:215:12) at WebWorkerMainTemplatePlugin.apply (D:\newtest\node_modules\vue-pdf\node_modules\webpack\lib\webworker\WebWorkerMainTemplatePlugin.js:139:35) at D:\newtest\node_modules\vue-pdf\node_modules\webpack\lib\webworker\WebWorkerTemplatePlugin.js:16:39 at Hook.eval [as call] (eval at create (D:\newtest\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:7:1) at Hook.CALL_DELEGATE [as _call] (D:\newtest\node_modules\tapable\lib\Hook.js:14:14) at Compiler.newCompilation (D:\newtest\node_modules\webpack\lib\Compiler.js:1121:30) at D:\newtest\node_modules\webpack\lib\Compiler.js:1166:29 at Hook.eval [as callAsync] (eval at create (D:\newtest\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:24:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (D:\newtest\node_modules\tapable\lib\Hook.js:18:14) at Compiler.compile (D:\newtest\node_modules\webpack\lib\Compiler.js:1161:28) at Compiler.runAsChild (D:\newtest\node_modules\webpack\lib\Compiler.js:561:8) at Object.pitch (D:\newtest\node_modules\vue-pdf\node_modules\worker-loader\dist\index.js:115:19)
看起来这是一个Webpack编译错误,可能与Vue-pdf或pdfjs-dist模块有关。您可以尝试以下步骤来解决此问题:
1. 确保您已经安装了最新版本的Vue-pdf和pdfjs-dist模块。
2. 如果您正在使用Vue CLI,请尝试删除node_modules文件夹并重新安装所有依赖项。
3. 如果问题仍然存在,请考虑升级您的Webpack版本或查看是否有任何相关的Webpack插件需要更新。
4. 最后,您可以尝试在Vue-pdf的GitHub仓库中查看是否有类似的问题,并查看是否有任何解决方案。
阅读全文
相关推荐
















