所以我試圖在我的專案中使用 jsPDF 但每當我嘗試將 jsPDF 匯入我的 vue 組件時,我都會收到此錯誤:
ERROR in ./node_modules/canvg/lib/index.es.js 1933:16-23
Module not found: Error: Can't resolve 'process/browser' in '/Users/air-1/Desktop/OneDrive - laravel projects/prevzemniDokumenti/node_modules/canvg/lib'
Did you mean 'browser.js'?
BREAKING CHANGE: The request 'process/browser' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
webpack compiled with 1 error
現在它說我必須向請求添加擴展名,但我不知道這意味著什么......試圖尋找解決方案,但我找不到解決方案所以現在我在這里。
我的 package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"autoprefixer": "^10.3.7",
"axios": "^0.21",
"jquery": "^3.6",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"popper.js": "^1.16.1",
"postcss": "^8.3.9",
"resolve-url-loader": "^3.1.2",
"tailwindcss": "^2.2.16",
"vue": "^2.6.12",
"vue-loader": "^15.9.8",
"vue-template-compiler": "^2.6.12"
},
"dependencies": {
"jspdf": "^2.4.0",
"vue-router": "^3.5.2"
}
}
我該如何解決這個錯誤?
uj5u.com熱心網友回復:
找到了解決辦法。
在 webpack.mix.js 我不得不添加
mix.options({legacyNodePolyfills: false})
在 mix.js 呼叫之前
https://github.com/laravel-mix/laravel-mix/issues/2737
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/348983.html
上一篇:如何在webpack.config.js中檢查監視模式?
下一篇:無法匯入節點模塊
