问题描述
出现如下问题
[ERROR] Could not resolve "dommatrix/dist/dommatrix.js"
node_modules/pdfh5/js/pdf.js:22:23008:
22 │ ...&&(globalThis.DOMMatrix=require("dommatrix/dist/dommatrix.js"))}();!function checkReadableSt...
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "dommatrix/dist/dommatrix.js" as external to exclude it from the bundle,
which will remove this error and leave the unresolved path in the bundle. You can also surround
this "require" call with a try/catch block to handle this failure at run-time instead of
bundle-time.
X [ERROR] Could not resolve "web-streams-polyfill/dist/ponyfill.js"
node_modules/pdfh5/js/pdf.js:22:23150:
22 │ ...his.ReadableStream=require("web-streams-polyfill/dist/ponyfill.js").ReadableStream)}();!func...
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "web-streams-polyfill/dist/ponyfill.js" as external to exclude it from the
bundle, which will remove this error and leave the unresolved path in the bundle. You can also
surround this "require" call with a try/catch block to handle this failure at run-time instead of
bundle-time.
一共两种问题:
[ERROR] Could not resolve "web-streams-polyfill/dist/ponyfill.js"
[ERROR] Could not resolve "dommatrix/dist/dommatrix.js"
问题解决
第一步先执行:
npm install canvas@2.8.0 --ignore-scripts
只执行npm install canvas会报新的错误
第二步执行:
npm install --save dommatrix
第三步执行:
npm install --save web-streams-polyfill
参考npm报错:These dependencies were not found:* canvas in ./node_modules/pdfh5/js/pdf.js* dommatrix/dist/d