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

Bug: Unable to resolve "@logto/client/shim" from "node_modules/@logto/rn/lib/index.js" #20

Open
1 of 4 tasks
alwyntan opened this issue Mar 7, 2024 · 22 comments
Open
1 of 4 tasks
Assignees
Labels
bug Something isn't working

Comments

@alwyntan
Copy link

alwyntan commented Mar 7, 2024

Describe the bug

@logto/client/shim seems to not be exported from @logto/client and errors.

Expected behavior

No crashes

How to reproduce?

Install @logto/rn and import in the root component.

Context

  • Logto Cloud
  • Self-hosted, Logto version =
    • Container (Docker image)
    • Raw Node.js
@alwyntan alwyntan added the bug Something isn't working label Mar 7, 2024
@alwyntan
Copy link
Author

alwyntan commented Mar 7, 2024

There might be some linking problems with @logto/client/shim, but I'm quite unfamiliar with how that is bundled. The naive way to fix this (which I have tried locally) is to just patch the node_modules for every file that references @logto/client/shim to @logto/client/lib/shim

@gao-sun
Copy link
Member

gao-sun commented Mar 11, 2024

I'll take a look on it. It seems somehow the resolver doesn't honor the exports filed in package.json.

@gao-sun
Copy link
Member

gao-sun commented Mar 11, 2024

Which RN/Expo version are you using?

@alwyntan
Copy link
Author

Using RN0.73.4 and expo 50.0.11

@shibilyt
Copy link

any progress in this? I am also facing the same issue.

@Mohamed-kassim
Copy link

Mohamed-kassim commented Apr 23, 2024

same issue here expo sdk50 any progress?
expo: 50.0.17 and expo router
@gao-sun

@elvingomezdev
Copy link

Same problem, any update?

expo: 50.0.14

@JakimLi
Copy link

JakimLi commented May 17, 2024

same issue, is this repo still being maintained? any update about this?

@flavindias
Copy link

same problem here, any updates?

@JakimLi
Copy link

JakimLi commented May 18, 2024

I did some exploration, and finally solved this issue, this is not working because react native does not support package exports by default, I did below config to make it work:

in metro.config.js , create if not exist.

const { getDefaultConfig } = require('expo/metro-config');  
// because I am using expo, so have to import expo's 
// default metro config, otherwise expo will complain with errors.

const config = getDefaultConfig(__dirname);

config.resolver.unstable_enablePackageExports = true;

module.exports = config;

this is the related react native doc: https://reactnative.dev/blog/2023/06/21/package-exports-support
hope this helps

@Housain-maina
Copy link

I did some exploration, and finally solved this issue, this is not working because react native does not support package exports by default, I did below config to make it work:

in metro.config.js , create if not exist.

const { getDefaultConfig } = require('expo/metro-config');  
// because I am using expo, so have to import expo's 
// default metro config, otherwise expo will complain with errors.

const config = getDefaultConfig(__dirname);

config.resolver.unstable_enablePackageExports = true;

module.exports = config;

this is the related react native doc: reactnative.dev/blog/2023/06/21/package-exports-support hope this helps

finally a fix, thanks

@gao-sun
Copy link
Member

gao-sun commented May 20, 2024

yes i'm working on the update. however i could not reproduce this issue. can you provide a repo for this issue?

if i can reproduce it, i'll also do a patch to fix this issue

@gao-sun
Copy link
Member

gao-sun commented May 20, 2024

@JakimLi thanks for providing the workaround. i'm curious of reproducing this issue because it went just fine on my laptop. even if i change import to require in packages/rn-sample.

@r3dm4n
Copy link

r3dm4n commented Jun 27, 2024

Adding this breaks axios for me.

[EDIT]
I have tried adding axios to the sample, and got the same result.

@r3dm4n
Copy link

r3dm4n commented Jun 27, 2024

Is there any fix for this ?

@isener
Copy link

isener commented Jul 8, 2024

I did some exploration, and finally solved this issue, this is not working because react native does not support package exports by default, I did below config to make it work:

in metro.config.js , create if not exist.

const { getDefaultConfig } = require('expo/metro-config');  
// because I am using expo, so have to import expo's 
// default metro config, otherwise expo will complain with errors.

const config = getDefaultConfig(__dirname);

config.resolver.unstable_enablePackageExports = true;

module.exports = config;

this is the related react native doc: https://reactnative.dev/blog/2023/06/21/package-exports-support hope this helps

This has sorted the issue!
Thanks a ton!!

EDIT:
This breaks react navigation. Still no workaround.

@simeng-li
Copy link
Contributor

Enabling packageExports in the Metro config is necessary to properly load @logto/client/shim. We've updated the integration documentation to include this information.

@isener, could you please share the detailed error information here?

It seems React Native needs to release a stable version that fully supports npm package exports.

@fvcoder
Copy link

fvcoder commented Oct 19, 2024

I did some exploration, and finally solved this issue, this is not working because react native does not support package exports by default, I did below config to make it work:

in metro.config.js , create if not exist.

const { getDefaultConfig } = require('expo/metro-config');  
// because I am using expo, so have to import expo's 
// default metro config, otherwise expo will complain with errors.

const config = getDefaultConfig(__dirname);

config.resolver.unstable_enablePackageExports = true;

module.exports = config;

this is the related react native doc: https://reactnative.dev/blog/2023/06/21/package-exports-support hope this helps

Works

@dipakparmar
Copy link

config.resolver.unstable_enablePackageExports = true;

Turning this on breaks other packages!

@simeng-li
Copy link
Contributor

@dipakparmar can you try the latest 0.4.0 release. We have removed the import of the shim package. unstable_enablePackageExports is no longer needed.

@dipakparmar
Copy link

@dipakparmar can you try the latest 0.4.0 release. We have removed the import of the shim package. unstable_enablePackageExports is no longer needed.

Hey @simeng-li Thanks. Did the quick test and it works. Will do full test later this weekend and let you know. But so far its working.

@dipakparmar
Copy link

Confirming, this is resolved. Can successfully build the app on iOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests