3

My app works fine in npm run dev &/or yarn run build && yarn start

But packaged version fails to find dependencies of dependencies, specifically 'react' within react-player or react-countup.

Uncaught Error: Cannot find module 'react' Require stack:

/Applications/ElectronReact.app/Contents/Resources/app.asar/node_modules/react-countup/build/index.js

/Applications/ElectronReact.app/Contents/Resources/app.asar/app.html at Module._resolveFilename (internal/modules/cjs/loader.js:717) at Function../lib/common/reset-search-paths.ts.Module._resolveFilename (reset-search-paths.ts:40) at Module._load (internal/modules/cjs/loader.js:622) at Module._load (electron/js2c/asar.js:717) at Function.Module._load (electron/js2c/asar.js:717) at Module.require (internal/modules/cjs/loader.js:775) at require (internal/modules/cjs/helpers.js:68) at Object. (/Applications/ElectronReact.app/Contents/Resources/app.asar/node_modules/react-countup/build/index.js:8) at Object. (/Applications/ElectronReact.app/Contents/Resources/app.asar/node_modules/react-countup/build/index.js:600) at Module._compile (internal/modules/cjs/loader.js:880)

internal/modules/cjs/loader.js:720

It's a React, Firebase, Redux, REST API app.

I checked it packaged and opened properly first before doing much with the boilerplate. Just stripped back some counter logic and put in some basic styling etc.

I have installed (firebase, react-player, react-countup) dependencies at app/package.json level not root/pkg json

Unsure how/why app's ability to find React would've changed by anything i've done. I dont think i've touched any config for a while. And even then it was the main.dev.js not main.prod.js - which looks like it's gone through a transpiler and i wouldn't know how to edit anyway.

electron app web dependency error

The nuts and bolts of this: Error suggests it's failing to find 'react' via the common JS loader, loading modular js into browser. That's when it's loading the react-countup package. If i remove that npm pkg and then re-package my app, it fails with same error on the next dependency i installed (react-player). If i kill that, it moves onto Prismic-ReactJS pkg.

Have i installed packages at the wrong level? (app/package.json) Do i need to link dependencies OF dependencies somehow? Is there a main.js setting somewhere that I've tweaked by accident?

Can anyone help?

Aid19801
  • 1,175
  • 1
  • 17
  • 30

0 Answers0