valeriangalliat / fetch-cookie

Decorator for a `fetch` function to support automatic cookie storage and population. 🍪
The Unlicense
135 stars 29 forks source link

Failed to load configuration of your project('./package.json' is not defined by "exports") #73

Closed rpopovici closed 2 years ago

rpopovici commented 2 years ago

I am getting this error with the latest version or react-native 0.69

[react-native] error Failed to load configuration of your project.
[react-native] Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in ../node_modules/fetch-cookie/package.json
[react-native]     at throwExportsNotFound (internal/modules/esm/resolve.js:299:9)
[react-native]     at packageExportsResolve (internal/modules/esm/resolve.js:522:3)
[react-native]     at resolveExports (internal/modules/cjs/loader.js:449:36)
[react-native]     at Function.Module._findPath (internal/modules/cjs/loader.js:489:31)
[react-native]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:875:27)
[react-native]     at Function.resolve (internal/modules/cjs/helpers.js:98:19)
[react-native]     at resolveNodeModuleDir (../node_modules/@react-native-community/cli-tools/build/resolveNodeModuleDir.js:24:42)
[react-native]     at ../node_modules/@react-native-community/cli-config/build/loadConfig.js:93:76
[react-native]     at Array.reduce (<anonymous>)
[react-native]     at loadConfig (../node_modules/@react-native-community/cli-config/build/loadConfig.js:91:134)
[react-native] info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
rpopovici commented 2 years ago

Doing this in fetch-cookie/package.json apparently fixes the problem:

  "exports": {
    "./package.json": "./package.json",
    ".": {
      "import": {
        "types": "./esm/index.d.ts",
        "default": "./esm/index.js"
      },
      "require": {
        "types": "./cjs/index.d.ts",
        "default": "./cjs/index-wrapper.js"
      }
    }
  },

Stole it from here https://github.com/uuidjs/uuid/pull/449

valeriangalliat commented 2 years ago

Thanks for reporting and finding the fix! Published with 2.1.0, let me know if it works for you =)

rpopovici commented 2 years ago

@valeriangalliat looks like it's working. Thanks!