[Solved] ERROR Failed to compile with 3 errors These dependencies were not found: * pdfjs-dist/es5/buil

introduction

Xiao Fang is a junior student. Today, he joined a front-end intern position in a company. He is so proud that he plans to do a big job. Results the card was stuck in NPM run build , and the error message was reported (as follows).

$ npm run build

> [email protected] build /usr/local/docker/gitlab-ee-12.4.1/builds/63s9Rzjq/0/dev_web/system
> vue-cli-service build --mode production


-  Building for production...
 ERROR  Failed to compile with 3 errors PM 3:24:46

These dependencies were not found:

* pdfjs-dist/es5/build/pdf.js in ./node_modules/[email protected]@cache-loader/dist/cjs.js??ref--12-0!./node_modules/[email protected]@thread-loader/dist/cjs.js!./node_modules/[email protected]@babel-loader/lib!./node_modules/[email protected]@cache-loader/dist/cjs.js??ref--0-0!./node_modules/[email protected]@vue-loader/lib??vue-loader-options!./node_modules/[email protected]@vue-pdf/src/vuePdfNoSss.vue?vue&type=script&lang=js&
* worker-loader!pdfjs-dist/es5/build/pdf.worker.js in ./node_modules/[email protected]@cache-loader/dist/cjs.js??ref--12-0!./node_modules/[email protected]@thread-loader/dist/cjs.js!./node_modules/[email protected]@babel-loader/lib!./node_modules/[email protected]@cache-loader/dist/cjs.js??ref--0-0!./node_modules/[email protected]@vue-loader/lib??vue-loader-options!./node_modules/[email protected]@vue-pdf/src/vuePdfNoSss.vue?vue&type=script&lang=js&
* pdfjs-dist/es5/web/pdf_viewer in ./node_modules/[email protected]@vue-pdf/src/pdfjsWrapper.js

To install them, you can run: npm install --save pdfjs-dist/es5/build/pdf.js worker-loader!pdfjs-dist/es5/build/pdf.worker.js pdfjs-dist/es5/web/pdf_viewer
 ERROR  Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `vue-cli-service build --mode production`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-06-08T07_24_46_457Z-debug.log
ERROR: Job failed: exit status 1

What? Can’t even run the project, so you have to be dissuaded on the first day of employment?! Reluctantly, he spent a whole day searching Baidu and Google, but he didn’t find the problem

After the meeting in the afternoon, the leader passed by his work station and saw Xiao Fang, who was in a mess, asked if the environment had been set up. At this time, Xiao Fang was already suffering from this problem and fed it back to the leaders. Unexpectedly, the leader gently put down the water cup in his hand and did a careful investigation on Xiao Fang’s work position. The leader quickly located the node_ However, it seems that this problem is rather intractable, and it has not been solved after half an hour. In the end, the leader put the node in his computer_ Moudels is copied, and the problem is found after replacement

it can be seen vaguely that Xiaofang installed the 2.8.335 version of pdfjs dist, while the leader used 2.5.207 , and this newer version is not compatible with the node environment, resulting in an error.

solve

The problem is that in the development team, the front-end project should not put the package lock. JSON file used to lock the version into gitignore, because the most critical factor of development is stability rather than the latest
hope to solve your problem, see you~

Read More: