# PDF Viewer not working in production build of buildScripts

**URL:** <https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985>\
**Category:** Technical Support\
**Created:** [December 5, 2023, 1:14pm UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985 "2023-12-05T13:14:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![nirmalkumar.r](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nirmalkumar.r](https://pdfjs.community/u/nirmalkumar.r)\
**Post date:** [December 5, 2023, 1:14pm UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/1 "2023-12-05T13:14:44Z")

</div>

Facing this issue in local npm build. Working fine in local NPM start execute.  
Able to confirm all static dependencies inside build under /webviewer/lib.  
Trying pdfviewer along with [Material Dashboard 2 React: Free MUI & React Admin Template @ Creative Tim](https://www.creative-tim.com/product/material-dashboard-react).

Please help me with your inputs.

**Which product are you using?**

**PDF.js Express Version**

**Detailed description of issue**  
{Description here}

**Expected behaviour**  
{Provide a screenshot or description of the expected behaviour}

**Does your issue happen with every document, or just one?**  
{Answer here}

**Link to document**  
{Provide a link to the document in question if possible}

**Code snippet**  
{Provide a relevant code snippet}

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [December 6, 2023, 7:52pm UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/2 "2023-12-06T19:52:38Z")

</div>

Hello Nirmalkumar,

Thank you for contacting us.

What version of Express are you using? Could you send us a minimal sample project or some way to reproduce the issue? A video of the issue would also be helpful.

Best Regards,  
Darian

---

<div class="post-metadata">

**Author:** ![nirmalkumar.r](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nirmalkumar.r](https://pdfjs.community/u/nirmalkumar.r)\
**Post date:** [December 7, 2023, 8:17am UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/3 "2023-12-07T08:17:04Z")

</div>

> [@darian.chen](#):
>
> Express

Hello Chen

Thanks for response.  
Hope your asking about “@pdftron/pdfjs-express-viewer”: “^8.7.4”.

We are not using express.js  
Also not able to share screen recorder of issue for your reference due upload size limit 8MB. Any other way to share screen reorder zip of 75MB  
Attached screensnap here. for your reference

Best Regards,  
NIrmal K  
[snapshots.zip](https://pdfjs.community/uploads/short-url/tWzI8a08ErZnQ53o2rpwJaWt9W7.zip) (443.8 KB)

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [December 7, 2023, 6:14pm UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/4 "2023-12-07T18:14:33Z")

</div>

Hi there,

From looking at your snapshots, I don’t see anything particularly wrong. Could you share your project by creating a repository on GitHub? For screen recording, you can use [https://www.loom.com/](https://www.loom.com/) or upload it to Google Drive.

Could you elaborate how you are using PDF.js Express with the material UI? We also have sample projects you can use available here: [PDF.js Express · GitHub](https://github.com/pdfjs-express)

We would need someway to reproduce the issue on our end in order assist further.

---

<div class="post-metadata">

**Author:** ![nirmalkumar.r](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nirmalkumar.r](https://pdfjs.community/u/nirmalkumar.r)\
**Post date:** [December 8, 2023, 3:21am UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/5 "2023-12-08T03:21:21Z")

</div>

Hello Chen

Please find recorded session in [Screen Recording (12-7-2023 1-34-33 PM).zip - Google Drive](https://drive.google.com/file/d/1pqT0n7prv0O7hFVmSJeU_qysslkeZyKu/view?usp=drive_link)

Trying to open pdfviewer inside **'@mui/material/DialogContent** on click on button.  
Issue is not able to construct WebViewer obj after getting valid current containerRef.

We did this in referred your GitHub sample projects and steps for react for viewer from your site.

Will be challenges to share our project in any repository.  
Hope this details will help to identify issue.

Thanks  
NIrmal Kumar

---

<div class="post-metadata">

**Author:** ![nirmalkumar.r](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nirmalkumar.r](https://pdfjs.community/u/nirmalkumar.r)\
**Post date:** [December 11, 2023, 3:12pm UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/6 "2023-12-11T15:12:23Z")

</div>

Chen,

Any inputs on above reported issues on pdfViewer

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [December 13, 2023, 6:32pm UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/7 "2023-12-13T18:32:55Z")

</div>

Hi there,

Thank you for the video and response. At the 3:05, I noticed the viewer not opening the PDF. When you try and open the PDF, could you open your console as well and check for any errors? Please provide a screenshot.

Thank you.

---

<div class="post-metadata">

**Author:** ![nirmalkumar.r](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nirmalkumar.r](https://pdfjs.community/u/nirmalkumar.r)\
**Post date:** [December 14, 2023, 2:54am UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/8 "2023-12-14T02:54:26Z")

</div>

Hi Chen

No errors in console when trying to open pdf. Also attached screenshot for your reference.

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/8/87c96ab0e2355c282ea688be0d9c8deb80e681fe.png)

Blocked with this issue for long time without any hint of issue. Please help with your support on this.

Thanks  
NIrmal KUmar.R

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [December 14, 2023, 6:00pm UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/9 "2023-12-14T18:00:34Z")

</div>

Hi there,

It is difficult to pinpoint the problem without some sort of sample project. Could you host this environment and send a way to access it? If you hover over the webviewer div, do you see it anywhere on the page?

---

<div class="post-metadata">

**Author:** ![nirmalkumar.r](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nirmalkumar.r](https://pdfjs.community/u/nirmalkumar.r)\
**Post date:** [December 15, 2023, 3:41am UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/10 "2023-12-15T03:41:33Z")

</div>

HI Chen

Please find snapshot where we can find webviewer div on hover.

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/1/15ca5888a6fa298301246b861d44a1c4992a551b.png)

---

<div class="post-metadata">

**Author:** ![nirmalkumar.r](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nirmalkumar.r](https://pdfjs.community/u/nirmalkumar.r)\
**Post date:** [December 15, 2023, 6:27am UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/11 "2023-12-15T06:27:56Z")

</div>

Chen,

Please find sample project here :  
[https://github.com/RNIrmalKumar133/material-dashboard-react-main.git](https://github.com/RNIrmalKumar133/material-dashboard-react-main.git)  
Snapshots

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/d/db874d2bab21d1feff0af8c588a308674b648390.png)

Hope this will help us to point out issue

Thanks & Regards  
NIrmal KUmar.R

---

<div class="post-metadata">

**Author:** ![nirmalkumar.r](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nirmalkumar.r](https://pdfjs.community/u/nirmalkumar.r)\
**Post date:** [December 15, 2023, 6:28am UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/12 "2023-12-15T06:28:27Z")

</div>

Additional snapshot of code

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/8/831841fb802b10b8f492f7d7a5988b14e42125ef.png)

---

<div class="post-metadata">

**Author:** ![nirmalkumar.r](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nirmalkumar.r](https://pdfjs.community/u/nirmalkumar.r)\
**Post date:** [December 15, 2023, 6:29am UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/13 "2023-12-15T06:29:16Z")

</div>

Snapshot how to trigger pdfviewer express

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/b/b0e9ea38a154b18b8d2e06d1ebc29fe0d18493a2.jpeg)

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [December 16, 2023, 12:00am UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/14 "2023-12-16T00:00:59Z")

</div>

Hi there,

The GitHub link you provided is not working.

---

<div class="post-metadata">

**Author:** ![nirmalkumar.r](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nirmalkumar.r](https://pdfjs.community/u/nirmalkumar.r)\
**Post date:** [December 21, 2023, 4:15am UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/15 "2023-12-21T04:15:08Z")

</div>

Chen

Apologies for delay response.  
Now Repository should be accessible  
Please find sample project here :  
[https://github.com/RNIrmalKumar133/material-dashboard-react-main.git](https://github.com/RNIrmalKumar133/material-dashboard-react-main.git)

Please help us to resolve it.  
Thanks & Regards  
NIrmal KUmar.R

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [December 22, 2023, 12:40am UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/16 "2023-12-22T00:40:41Z")

</div>

Hi there,

I was able to successfully run your project. I ran npm start to see it in development. As expected the viewer appeared without any issue when I clicked “CLICK TO OPEN AGREEMENT FILE” under billing. However, when I ran npm run build and started that project, I was still able to see the PDF as well.

 ![Screenshot 2023-12-21 at 7.38.32 PM](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/2/211f7d965654650b7e3ba50fb3e332749e85b7f0.png)

---

<div class="post-metadata">

**Author:** ![nirmalkumar.r](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nirmalkumar.r](https://pdfjs.community/u/nirmalkumar.r)\
**Post date:** [December 22, 2023, 10:14am UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/17 "2023-12-22T10:14:57Z")

</div>

Chen,

That is surprising!!  
Still it is not working in build mode. NOT able to see PDF  
Attached screenshot

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/f/f79b4203620edeba5fe96ffe37f7a8daa6f14d60.png)

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [December 26, 2023, 5:59pm UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/18 "2023-12-26T17:59:07Z")

</div>

Hello,

I am able to see the viewer in build mode.

I took the following steps:

1. run `npm run build`
2. cd build
3. run `npm run start`

Then I navigated to billing and “CLICK TO OPEN AGREEMENT FILE”.

 ![Screenshot 2023-12-21 at 7.38.32 PM](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/2/211f7d965654650b7e3ba50fb3e332749e85b7f0.png)

Does this happen on other devices or browsers?

---

<div class="post-metadata">

**Author:** ![nirmalkumar.r](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nirmalkumar.r](https://pdfjs.community/u/nirmalkumar.r)\
**Post date:** [December 27, 2023, 7:10am UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/19 "2023-12-27T07:10:34Z")

</div>

Hello Chen,

Yes, able to view pdf with above steps only.

**Cant** we able to achieve same using following steps

1. run `npm run build`
2. run `serve -s build`

I have ci/cd process with above steps for other functionalities to work. Why need to run `npm run start` under build folder for this.

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [December 28, 2023, 9:54pm UTC](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985/20 "2023-12-28T21:54:03Z")

</div>

Hello there,

We are currently looking into this and will provide an update when we have more information.

[Next page](https://pdfjs.community/t/pdf-viewer-not-working-in-production-build-of-buildscripts/2985.md?page=2)
