[BUG] Does not work with pnpm
Describe the bug When using pnpm as a package manager reassure binary cannot be found. After running command pnpm reassure i get:
ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL not found: reassure
I noticed that reassure binary is missing in the node_modules/.bin folder.
To Reproduce Steps to reproduce the behavior:
- Create react project with create-react-app
- Add reassure to the project using pnpm add reassure -D
- run pnpm reassure
@mczapkowicz you are right, we did not test pnmp compatibility. That the issue you are facing should be relatively easy to work around: you can set TEST_RUNNER_PATH env variable to proper reassure CLI path.
Thanks for the answer @mdjastrzebski . Yes, I tried that already by running fallowing command:
TEST_RUNNER_PATH=node_modules/reassure/node_modules/.bin/reassure pnpm reassure
but the error still occurs.
Is that the same error or different one? Pls paste exact error details.
Yes, the error is exactly the same:
ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL not found: reassure
I think we've confusing two things here. One is TEST_RUNNER_PATH which should have path to test runner, e.g. Jest While you issue seems to be about executing Reassure CLI itself. Since this is a simple node executable you should be able to run it using:
-
node node_modules/reassure/node_modules/.bin/reassure - or:
node node_modules/.bin/reassure - or
./node_modules/reassure/node_modules/.bin/reassure
-
TEST_RUNNER_PATH=node_modules/.bin/jest node node_modules/reassure/node_modules/.bin/reassure
gives me:
/Users/user/Desktop/test-project/node_modules/.pnpm/[email protected][email protected]/node_modules/reassure/node_modules/.bin/reassure:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
-
node node_modules/.bin/reassure, gives:Cannot find module '/Users/user/Desktop/test-project/node_modules/.bin/reassurewhich makes sense because, like I said there is no reassure in node_modules/.bin folder -
./node_modules/reassure/node_modules/.bin/reassuregives
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '/Users/user/Desktop/test-project/@[email protected]/node_modules/@callstack/reassure-cli/lib/commonjs/bin.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
@mczapkowicz:
- what OS are you using? Another used reported the first error (
=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")) for Windows env. - could you try to use it with
yarnornpm? I wonder if this is more OS-specific of package manager specific?
I'm using macOS. Everything works fine with yarn and npm so I belive this is package manager specific. This may be caused by the fact that contrary to npm and yarn module hoisting, pnpm uses non-flat node_modules structure. So with npm and yarn node_modules inside reassure are getting hoisted including .bin - with pnpm they are not.
@mczapkowicz do you have some available time and would like to bring PNMP support to Reassure? 😀
The issue here seems to be specific to how PNPM works rather than the actual Reassure code.
I will take a look at this.
Same problem here using on macOS, seems related to pnpm indeed.
For anyone that may benefit, i was able to make this work with pnpm in a slightly ugly but temporarily acceptable way like this:
TEST_RUNNER_PATH=node_modules/jest/bin/jest ../../node_modules/.pnpm/[email protected][email protected]/node_modules/reassure/node_modules/.bin/reassure
Note that this exact solution may not work for everyone as it relies on relative path. Takeway here is that for test runner we rely on js file instead of binary and as reassure binary we seek the root installation of reassure instead of relying on symlinks, in which case relative paths inside that binary work fine
Will try to submit a PR so that hacking like this is not required
It seems the issue has been resolved. I successfully installed and ran Reassure in pnpm + Vite + ts-jest and pnpm + CRA + Vite environments, and it worked perfectly 👌
Can someone involved confirm this?