question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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® Core™ 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:

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13

github_iconTop GitHub Comments

2reactions
ctavancommented, 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: https://github.com/react-native-community/cli/issues/1168

0reactions
ctavancommented, Jan 10, 2021

I believe this should still be fixed through https://github.com/react-native-community/cli/issues/1168

Read more comments on GitHub >

github_iconTop Results From Across the Web

package.json is not defined by "exports" · Issue #444 - GitHub
I don't get a stack trace and I am not using rollup. warn Package uuid has been ignored because it contains invalid configuration....
Read more >
Package subpath is not defined by "exports" - Stack Overflow
You problem sound like a dependance problem. First, try to delete node_modules directory and issue a npm install in order to re import ......
Read more >
9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d - You.com
(Error: Package subpath './types' is not defined by "exports" in D:\Projects\pets\realtime-chat\backend\node_modules\sequelize\package.json).
Read more >
Support "exports" field of package.json : WEB-40509 - YouTrack
Open index.js . · Try navigating to definition of HelloDependency from the statement where the instance is constructed. · Delete the import statement...
Read more >
Package exports - webpack
The exports field in the package.json of a package allows to declare which module should be used when using module requests like import...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found