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

RN and Node 14+ is missing package.json in "export" field in package.json #9178

Open
ospfranco opened this issue Jul 5, 2022 · 2 comments
Open

Comments

@ospfranco
Copy link

Issue Description

Expected Behavior

TypeORM should work just fine with RN and Node 14+ (since Node12 will eventually be retired)

Actual Behavior

Since Node 14+ all files that are meant to be accessed from third-parties need to be declared in the package.json "export" field. Current configuration is mostly fine, but React Native also reads the package.json. Since this field is not specified the react native packager is not able to link the package and it fails the import on runtime.

You can see a more detailed issue here:

react-native-community/cli#1168

I've locally fixed the issue in my node_modules by changing:

"./package.json": "./package.json", // <-- added this line on typeorm package.json exports field
"./*.js": "./*.js",

Steps to Reproduce

  1. On any react-native project using a node 14+ version trying installing typeorm
  2. try running the app, there will be a package.json.js file not found:
warn Package typeorm has been ignored because it contains invalid configuration. Reason: Cannot find module '/Users/osp/Developer/quick-sqlite/example/node_modules/typeorm/package.json.js'

My Environment

Dependency Version
Operating System macos
Node.js version 16.14.2
TypeORM version 0.3.7

Additional Context

Relevant Database Driver(s)

DB Type Reproducible
aurora-mysql no
aurora-postgres no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb no
mysql no
nativescript no
oracle no
postgres no
react-native yes
sap no
spanner no
sqlite no
sqlite-abstract no
sqljs no
sqlserver no

Are you willing to resolve this issue by submitting a Pull Request?

  • ✖️ Yes, I have the time, and I know how to start.
  • ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✅ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
@hengkx
Copy link

hengkx commented Jul 21, 2022

 Invalid `Podfile` file: 767: unexpected token at 'Error: Cannot find module 'xxxxx/node_modules/typeorm/package.json.js'

    at createEsmNotFoundErr (node:internal/modules/cjs/loader:960:15)

    at finalizeEsmResolution (node:internal/modules/cjs/loader:953:15)

    at resolveExports (node:internal/modules/cjs/loader:482:14)

    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)

    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)

    at Function.resolve (node:internal/modules/cjs/helpers:108:19)

    at resolveNodeModuleDir (xxxxx/node_modules/@react-native-community/cli-tools/build/resolveNodeModuleDir.js:24:42)

    at xxxxx/node_modules/@react-native-community/cli-config/build/loadConfig.js:93:76

    at Array.reduce (<anonymous>)

    at loadConfig (xxxxx/node_modules/@react-native-community/cli-config/build/loadConfig.js:91:134)

@megabeehothanhminh
Copy link

Screen Shot 2022-07-21 at 11 37 33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants