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

Warning: Ignored package due to "Package subpath './package.json' is not defined by "exports"" #28710

Closed
omonk opened this issue Apr 21, 2020 · 15 comments
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@omonk
Copy link

omonk commented Apr 21, 2020

Description

I'm using i18next for translations, recently a backend connector for getting translation files was deprecated and replaced with a new package, i18next-http-backend.

Initially firing up the app metro throws as it is unable to resolve getFetch.cjs, adding the follow to metro.config.js removes this error:

const { getDefaultValues } = require("metro-config/src/defaults");
const {
  resolver: { sourceExts }
} = getDefaultValues();
///
module.exports = {
  resolver: {
    extraNodeModules,
    sourceExts: [...sourceExts, "cjs"]
  },
}

Next, when firing up the app with react-native start with the new package the console shows a warning:

warn Package i18next-http-backend has been ignored because it contains invalid configuration. Reason: Package subpath './package.json' is not defined by "exports" in /path/to/app/node_modules/i18next-http-backend/package.json

Looking closer into the package.json I can see it's using the latest module resolution for cjs and esm environments.

However, loading up the app on xcode simulator, the relevant requests are performed correctly and the right translation files are downloaded without any issues.

Question is, where is the warning coming from and should we be concerned?

React Native version:

System:
OS: macOS 10.15.2
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 299.27 MB / 16.00 GB
Shell: 3.0.2 - /usr/local/bin/fish
Binaries:
Node: 13.13.0 - /usr/local/bin/node
Yarn: 1.22.4 - ~/.yarn/bin/yarn
npm: 6.14.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 27, 28
Build Tools: 28.0.3, 29.0.2, 30.0.0
System Images: android-29 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.6010548
Xcode: 11.4/11E146 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. In any react-native project > yarn add i18next-http-backend
  2. Run > react-native start, N.B. you wont need to import the package from anywhere, I assume this warning is produced from some sort of analysis of root package.json dependencies.
  3. See warning as first output from react-native scripts
    warn Package i18next-http-backend has been ignored because it contains invalid configuration. Reason: Package subpath './package.json' is not defined by "exports" in /path/to/app/node_modules/i18next-http-backend/package.json

Expected Results

No warning is shown in the console

Snack, code example, screenshot, or link to a repository:

@omonk
Copy link
Author

omonk commented Apr 21, 2020

Moving to metro repo

@omonk omonk closed this as completed Apr 21, 2020
@alfonsocj
Copy link
Collaborator

@omonk how did you solve this?

@omonk
Copy link
Author

omonk commented Apr 23, 2020

Hey @alfonsocj, I've not managed to solve it, it does seems to just work but not super comfortable with it. Do you have the same thing?

@alfonsocj
Copy link
Collaborator

Right. I have the exact same problem.

@omonk
Copy link
Author

omonk commented Apr 23, 2020

I got sidetracked and haven't opened an issue in metro, I've found some other issues opened on the metro repo but nothing seems to of come from it:

Initial discussion regarding module exports: ai/nanoevents#44
Metro issue thats not had any comments: facebook/metro#535

Does your import with the warning make it into the bundle?

@omonk omonk reopened this Apr 23, 2020
@alfonsocj
Copy link
Collaborator

alfonsocj commented Apr 23, 2020

I do not see the warning after modifying metro.config.json. Everything seems to work fine.

@omonk
Copy link
Author

omonk commented Apr 23, 2020

Out of curiosity which package is it that you're seeing this happen with? And which RN version?

@jethrolarson
Copy link

Reverting node to LTS fixed this for me.

@adrai
Copy link

adrai commented May 13, 2020

@ctavan
Copy link

ctavan commented May 13, 2020

A workaround seems to be that every single module on npm adds package.json to their pkg.exports field.

However, especially since other bundlers like webpack and rollup, which also pull configuration from package.json, don't seem to suffer this issue, it might make more sense to fix this in react-native: react-native-community/cli#1168

@stale
Copy link

stale bot commented Aug 16, 2020

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added Stale There has been a lack of activity on this issue and it may be closed soon. and removed Stale There has been a lack of activity on this issue and it may be closed soon. labels Aug 16, 2020
@stale
Copy link

stale bot commented Dec 25, 2020

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 25, 2020
@ctavan
Copy link

ctavan commented Jan 10, 2021

I believe this should still be fixed through react-native-community/cli#1168

@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 21, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

5 participants