当前位置: 首页 > 工具软件 > Buildes > 使用案例 >

pdfjs-dist/es5/build/pdf.js not found找不到原因记录

聂炜
2023-12-01

These dependencies were not found:
pdfjs-dist/es5/build/pdf.js in ./node_modules/cache-loader/dist/cjs.js??ref-12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref-0-0!./node_modules/vue-loader/lib??vue-loader-options!./node_modules/vue-pdf/src/vuePdfNoSss.vue?vue&type=script&lang=js&
worker-loader!pdfjs-dist/es5/build/pdf.worker.js in ./node_modules/cache-loader/dist/cjs.js??ref-12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref-0-0!./node_modules/vue-loader/lib??vue-loader-options!./node_modules/vue-pdf/src/vuePdfNoSss.vue?vue&type=script&lang=js&
pdfjs-dist/es5/web/pdf_viewer in ./node_modules/vue-pdf/src/pdfjsWrapper.js

vue-pdf版本:4.2.0
问题代码:/node_modules/vue-pdf/src/vuePdfSss.vue

var PDFJS = require('pdfjs-dist/es5/build/pdf.js');

vue-pdf4.2.0版本自身依赖下来的pdfjs-dist并没有es5目录,导致build失败,
分析:版本依赖肯定不是空穴来风这么写,肯定有某个版本是有这个目录的,于是
我们需要找个有es5目录的版本覆盖pdfjs
package.json内容修改:

{
	"dependencies": {
		...
		"pdfjs-dist": "2.5.207",
		"vue-pdf": "^4.2.0",
		...
	}
}

然后就可以愉快地build了。

 类似资料: