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

Pod install fails with react-native build which includes luxon #1238

Closed
ajp8164 opened this issue Jul 11, 2022 · 3 comments · Fixed by #1239
Closed

Pod install fails with react-native build which includes luxon #1238

ajp8164 opened this issue Jul 11, 2022 · 3 comments · Fixed by #1239

Comments

@ajp8164
Copy link

ajp8164 commented Jul 11, 2022

Describe the bug
For a react-native project; can't install luxon and pod install. Reported error is..

[!] Invalid `Podfile` file: 783: unexpected token at 'Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in /Users/Andy/Development/ajp/AwesomeProject/node_modules/luxon/package.json

    at new NodeError (node:internal/errors:388:5)

    at throwExportsNotFound (node:internal/modules/esm/resolve:440:9)

    at packageExportsResolve (node:internal/modules/esm/resolve:719:3)

    at resolveExports (node:internal/modules/cjs/loader:488:36)

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

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

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

    at resolveNodeModuleDir (/Users/Andy/Development/ajp/AwesomeProject/node_modules/@react-native-community/cli-tools/build/resolveNodeModuleDir.js:24:42)

    at /Users/Andy/Development/ajp/AwesomeProject/node_modules/@react-native-community/cli-config/build/loadConfig.js:93:76

    at Array.reduce (<anonymous>)

info Run CLI with --verbose flag for more details.
'.

To Reproduce

  1. Create new react native project using npx react-native init AwesomeProject
  2. cd AwesomeProject && npm i && cd ios && pod install && cd ..
  3. npm i luxon
  4. cd ios && pod install => produces error stated above

Works => npm uninstall luxon && cd ios && pod install

Actual vs Expected behavior
Expect the project to build.

Desktop (please complete the following information):

  • Node 18.4.0
  • Luxon version 3.0.1
  • Ruby 2.7.5
  • Cocoapods 1.11.3

Additional context
React native project uses react 18 and RN 0.69.1

@hatem-72
Copy link
Contributor

hatem-72 commented Jul 11, 2022

Good catch.
Personally I had no reference to luxon in my error logs when running pod install.
So it took me a while to catch the culprit. But indeed luxon v3.0.1 caused an error on pod install for RN projects.

[!] Invalid `Podfile` file: source is not valid JSON!

 #  from /path-to-my-project/ios/Podfile:8
 #  -------------------------------------------
 #  target 'MyProject' do
 >    config = use_native_modules!
 #
 #  -------------------------------------------

@hatem-72
Copy link
Contributor

hatem-72 commented Jul 11, 2022

In fact problem did not appear in v3.0.1 but in v2.5.0.
You can check changes here.
I guess it comes from the Support for ESM-style node imports part.

@hatem-72
Copy link
Contributor

hatem-72 commented Jul 11, 2022

Exporting ./package.json inside luxon package.json seems to fix the issue.
I thought of doing this after running yarn react-native config.

I will submit a PR.

  "exports": {
    ".": {
      "import": "./src/luxon.js",
      "require": "./build/node/luxon.js"
    },
+   "./package.json": "./package.json",
  },

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

Successfully merging a pull request may close this issue.

2 participants