Galooshi / happo

Visual diffing in CI for user interfaces
504 stars 16 forks source link

Unable to run `happo-example-react-native-project` #196

Closed spikebrehm closed 7 years ago

spikebrehm commented 7 years ago

I'm unable to run happo-example-react-native-project, which is blocking me from iterating on happo-target-react-native. When I run

npm run --silent happo

I get:

module.js:471
    throw err;
    ^

Error: Cannot find module 'happo-target-react-native'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/spike/code/happo/packages/happo-example-react-native-project/.happo.js:1:89)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

which is confusing because I do see happo-target-react-native in node_modules:

$ ls node_modules/happo-target-react-native
lrwxr-xr-x  1 spike  admin    31B Mar 31 08:41 node_modules/happo-target-react-native -> ../../happo-target-react-native

If I change the require statement to require ../happo-target-react-native:

diff --git a/packages/happo-example-react-native-project/.happo.js b/packages/happo-example-react-native-project/.happo.js
index c662320..becc196 100644
--- a/packages/happo-example-react-native-project/.happo.js
+++ b/packages/happo-example-react-native-project/.happo.js
@@ -1,4 +1,4 @@
-const ReactNativeTarget = require('happo-target-react-native');
+const ReactNativeTarget = require('../happo-target-react-native');
 const S3Uploader = require('../happo-uploader-s3');

I get the same error:

module.js:471
    throw err;
    ^

Error: Cannot find module '../happo-target-react-native'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/spike/code/happo/packages/happo-example-react-native-project/.happo.js:1:89)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

Any tips? Could this be related to the Lerna setup?

trotzig commented 7 years ago

I haven't tried out the react-native project much at all, but I was able to at least get past your issue by first going to the root of the project, then running

npm run lerna bootstrap

(You can run lerna bootstrap as well, given that you have it installed and on the right version).

Let me know if that helps!

spikebrehm commented 7 years ago

Thanks for the reply. I tried running:

npm run lerna bootstrap

But lerna is not a script listed in package.json, so I got an error. So instead, I ran:

./node_modules/.bin/lerna bootstrap

Which did not fix the issue. I had done this initially before, as well.

spikebrehm commented 7 years ago

Oh, the issue was that happo-target-react-native had never been built with Babel, so the lib/index.js file, which was the main in package.json, did not exist. Running

npm run build:server

from happo-target-react-native fixed it 👍.

trotzig commented 7 years ago

Glad you got it sorted!