npm:启动项目时报错: error in ./node_modules/pdfjs-dist/build/pdf.js

一,报错信息:

$ npm run dev

> saas_dingo@1.0.0 dev
> vue-cli-service serve --mode development --open

 INFO  Starting development server...
10% building 2/2 modules 0 active[HPM] Proxy created: [Function: context]  ->  https://saas-api.taihuoniao.com
[HPM] Proxy rewrite rule created: "^/api" ~> ""
69% building 2735/2764 modules 29 active ...ode_modules/url-loader/dist/cjs.js??ref--1-0!/data/vue_thn/pd-saas-master/src/assets/images/tools/project_management/default_member.png[BABEL] Note: The code generator has deoptimised the styling of /data/vue_thn/pd-saas-master/lib/js/pdfmake.min.js as it exceeds the max of 500KB.
69% building 2911/2947 modules 36 active /data/vue_thn/pd-saas-master/node_modules/url-loader/dist/cjs.js??ref--1-0!/data/vue_thn/pd-saas-master/src/assets/images/crm/01Trace.png[BABEL] Note: The code generator has deoptimised the styling of /data/vue_thn/pd-saas-master/lib/js/vfs_fonts.js as it exceeds the max of 500KB.
98% after emitting CopyPlugin

 ERROR  Failed to compile with 1 error                                                                                                                                      21:11:26

 error  in ./node_modules/pdfjs-dist/build/pdf.js

Module parse failed: Unexpected character '#' (1413:9)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| 
| class PDFDocumentLoadingTask {
>   static #docId = 0;
| 
|   constructor() {

二,解决:

手动安装报错的库:

$ npm i pdfjs-dist@2.0.943

然后再次运行,可以正常运行:

DONE  Compiled successfully in 55621ms                                                                                                                                     21:21:26


  App running at:
  - Local:   http://localhost:8070/ 
  - Network: http://192.168.204.221:8070/

  Note that the development build is not optimized.
  To create a production build, run npm run build.

 

posted @ 2026-01-15 21:33  刘宏缔的架构森林  阅读(4)  评论(0)    收藏  举报