Home > database >  npm run build failing
npm run build failing

Time:02-20

I am trying to build my react and node.js web app but fail to build ever since fixing packages.

i get the following error


Module not found: Error: Can't resolve 'fs' in 'my-app/node_modules/dotenv/lib'


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
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.

I have tried to clear the cache of node_modules, remove package-lock.json, re install with npm and re-build, but nothing works.

Does anyone know how to solve this please?

CodePudding user response:

Node Core Modules like fs won't work in the browser because they require binaries that aren't present in the browser. It apparently has been stubbed out of create-react-app, as per this Github issue.

The web doesn't have a filesystem, so it makes sense it won't ever work. Unfortunately for you, it means you should find a workaround. What were you trying to achieve with fs ?

CodePudding user response:

This may be a short hand fix, but i removed the dotenv package and loaded my env variables into the Azure config variables.

  • Related