Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module not found: Error: Can't resolve 'zlib'

Tags:

reactjs

I am trying to migrate a CRA react application to NX, following steps on the official site

When I hit nx serve

I am facing the following error:

ERROR in C:/dev/nx-dev/scandy/node_modules/@react-pdf/png-js/dist/png-js.browser.es.js Module not found: Error: Can't resolve 'zlib' in 'C:\dev\nx-dev\scandy\node_modules@react-pdf\png-js\dist'

ERROR in C:/dev/nx-dev/scandy/node_modules/@react-pdf/pdfkit/dist/pdfkit.browser.es.js Module not found: Error: Can't resolve 'zlib' in 'C:\dev\nx-dev\scandy\node_modules@react-pdf\pdfkit\dist'

Knowing that: before I start migration my project worked fine.

npm version: 6.14.11

node version: 14.16.0

I've tried to hit npm install zlib yet I get

Cannot find module './zlib_bindings'

like image 891
Abdulrahman Falyoun Avatar asked Dec 20 '25 05:12

Abdulrahman Falyoun


1 Answers

For some reason, VSCode inserted import e from 'express' at the top of my file in react

import { response } from 'express';

I delete the above import line and then the problem is resolved, all the errors are gone after the above change.

like image 75
Selçuk YAPICI Avatar answered Dec 23 '25 00:12

Selçuk YAPICI