Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing in a new react-native project: missing yarn.lock #23

Open
loredanacirstea opened this issue Nov 22, 2024 · 7 comments · Fixed by #24
Open

Installing in a new react-native project: missing yarn.lock #23

loredanacirstea opened this issue Nov 22, 2024 · 7 comments · Fixed by #24
Labels
bug Something isn't working released

Comments

@loredanacirstea
Copy link

tldr;
Add the yarn.lock file to the npm published package.
Otherwise, if you use this package in a new RN app, you will need to manually add it. But if you cd ./node_modules/@berty/weshnet-expo && yarn you may encounter some bundling issues, so I just copied yarn.lock from the @berty/weshnet-expo repo and it worked.

  • new expo project, I installed npx expo install @berty/weshnet-expo and then rebuilt ios/android:
$ npx expo prebuild --clean
✔ Cleared android, ios code
✔ Created native directories
✔ Updated package.json | no changes
✔ Finished prebuild
⚠️  Something went wrong running `pod install` in the `ios` directory.
Command `pod install` failed.
└─ Cause: /bin/bash -c
set -e
make -C .. build.ios

make: *** No rule to make target `yarn.lock', needed by `node_modules'.  Stop.

pod install --repo-update --ansi exited with non-zero code: 1

I see that node_modules/@berty/weshnet-expo does not contain yarn.lock, which seems to be required by the build process in node_modules/@berty/weshnet-expo/Makefile.

So I did a yarn in node_modules/@berty/weshnet-expo, I got the following errors:

$ expo-module prepare && sh prepare.sh
Configuring module
expo-module-scripts: README.md exists, not updating
src/api/index.ts:1:10 - error TS2305: Module '"./protocoltypes.pb"' has no exported member 'default'.

1 import { default as protocolpb } from './protocoltypes.pb'
           ~~~~~~~

src/api/index.ts:2:10 - error TS2305: Module '"./rpcmanager.pb"' has no exported member 'default'.

2 import { default as rpcmanagerpb } from './rpcmanager.pb'
           ~~~~~~~

src/error.ts:2:8 - error TS1192: Module '"/Users/user/mobile/amigo/amigo/node_modules/@berty/weshnet-expo/src/api/index"' has no default export.

2 import types from './api/index.d'
         ~~~~~

src/rpc/rpc.bridge.ts:6:8 - error TS1192: Module '"/Users/user/mobile/amigo/amigo/node_modules/@berty/weshnet-expo/src/api/index"' has no default export.

6 import types from '../api/index.d'
         ~~~~~

src/weshnet.types.gen.ts:2:8 - error TS1192: Module '"/Users/user/mobile/amigo/amigo/node_modules/@berty/weshnet-expo/src/api/index"' has no default export.

2 import api from './api/index.d'
         ~~~
Found 5 errors in 4 files.

Errors  Files
     2  src/api/index.ts:1
     1  src/error.ts:2
     1  src/rpc/rpc.bridge.ts:6
     1  src/weshnet.types.gen.ts:2
error Command failed with exit code 2.

If I ignore the above errors, npx expo prebuild --clean executes without errors. But running on the ios simulator gives a runtime error, because the build process did not finalize and the pb.js files were not included in the build.

iOS Bundling failed 4672ms node_modules/expo/AppEntry.js (752 modules)
Unable to resolve "./protocoltypes.pb" from "node_modules/@berty/weshnet-expo/build/api/index.js"

So I reinstalled weshnet-expo, copied the yarn.lock from this repo, rebuilt and the ios app seems to work correctly.

@D4ryl00
Copy link
Contributor

D4ryl00 commented Nov 22, 2024

Hello, thanks for your issue.
We have an entry in .npmignore to don't ignore yarn.lock. I'll dig why it is excluded.

Copy link

🎉 This issue has been resolved in version 1.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jefft0
Copy link
Collaborator

jefft0 commented Nov 25, 2024

Hello @loredanacirstea . Please see the latest commit which should resolve your issue.

@loredanacirstea
Copy link
Author

with the latest version I get

iOS Bundling failed 7931ms node_modules/expo/AppEntry.js (1734 modules)
Unable to resolve "./protocoltypes.pb" from "node_modules/@berty/weshnet-expo/build/api/index.js"

at npx expo prebuild --clean the build/api/*.pb.js files are removed, even though they are present after npm install

I assume it is because a new build is forced, but there are bundling errors, that I mentioned in my original issue.

@bluesliverx
Copy link

I have the exact same problem as @loredanacirstea currently. Copying the pb files back into node_modules/@berty/weshnet-expo/build/api fixes the issue, but this should definitely be fixed.

@jefft0
Copy link
Collaborator

jefft0 commented Nov 26, 2024

The following commands work for me. Can you give the exact commands which cause a problem?

npx create-expo-app@latest testexpo
cd testexpo
npx expo install @berty/weshnet-expo
npx expo prebuild --clean -p ios

@loredanacirstea
Copy link
Author

@jefft0 I can confirm that those commands are successful. The issue is at runtime.

Add in _layout.tsx:

import * as WeshnetExpo from "@berty/weshnet-expo";
console.log("WeshnetExpo",  WeshnetExpo.init())

Then npm run ios and you will see the error on the device/simulator.

@jefft0 jefft0 reopened this Nov 26, 2024
@jefft0 jefft0 added the bug Something isn't working label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants