cypress-io / instrument-cra

Little module for CRA applications to instrument code without ejecting react-scripts
MIT License
64 stars 17 forks source link

Not working with pnpm #227

Open Vader699 opened 2 years ago

Vader699 commented 2 years ago

I have an app that was using this with npm. I switched to pnpm to install packages and now get this error for the same script.

> training-react@0.2.0 start E:\app
> react-scripts -r @cypress/instrument-cra start

E:\app\node_modules\.pnpm\@cypress+instrument-cra@1.4.0\node_modules\@cypress\instrument-cra\index.js:72
require.cache[webpackConfigPath].exports = fakeConfig
                                         ^

TypeError: Cannot set property 'exports' of undefined
    at Object.<anonymous> (E:\app\node_modules\.pnpm\@cypress+instrument-cra@1.4.0\node_modules\@cypress\instrument-cra\index.js:72:42)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at Module._preloadModules (internal/modules/cjs/loader.js:1244:12)
    at loadPreloadModules (internal/bootstrap/pre_execution.js:475:5)
    at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:72:3)
    at internal/main/run_main_module.js:7:1
 ELIFECYCLE  Command failed with exit code 1.
ekolga commented 2 years ago

I'm getting the same error using "rush" tool. Any updates on that?

RHeynsZa commented 1 year ago

Same issue with yarn and executing inside the cypress node docker

bafficoluca commented 1 year ago

I'm having the same issue with pnpm (trying to switch from npm to pnpm).

bilegjargal-jargalsaikhan commented 1 year ago

I am having the same issue. Any workarounds?

bilegjargal-jargalsaikhan commented 1 year ago

If you are running inside the docker container, check out the node_modules path. My case was webpackConfigPath is different than where the actual node_modules folder is located.

check the require.cache object here https://github.com/cypress-io/instrument-cra/blob/1dda521a1260122a5c3ee0d4f6e766c22fffdf72/index.js#L72 to see if there are the /node_modules/react-scripts/config/webpack.config.js property exist