Description
openedon Sep 22, 2024
Description
I'm updating @react-native-vector-icons/common to be in line with the latest create-react-native-libarary.
I modified the codegenConfig in my package.json and the package was no longer being discovered when I run "react-native codegen"
The code that does this ignores errors in a libraries project.json. The error was
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in /home/johnf/work/inodes/react-native-vector-icons/node_modules/@react-native-vector-icons/common/package.json
at exportsNotFound (node:internal/modules/esm/resolve:304:10)
at packageExportsResolve (node:internal/modules/esm/resolve:651:9)
at resolveExports (node:internal/modules/cjs/loader:634:36)
at Module._findPath (node:internal/modules/cjs/loader:724:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1211:27)
at Function.resolve (node:internal/modules/helpers:190:19)
at /home/johnf/work/inodes/react-native-vector-icons/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js:241:38
at Array.flatMap (<anonymous>)
at findExternalLibraries (/home/johnf/work/inodes/react-native-vector-icons/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js:239:36)
at findCodegenEnabledLibraries (/home/johnf/work/inodes/react-native-vector-icons/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js:538:10) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Packages
- create-react-native-library
- react-native-builder-bob
Selected options
I fixed this by adding the following to package.json
diff --git a/packages/common/package.json b/packages/common/package.json
index fc67253..20ec4aa 100644
--- a/packages/common/package.json
+++ b/packages/common/package.json
@@ -6,6 +6,7 @@
"main": "./lib/commonjs/index.js",
"module": "./lib/module/index.js",
"exports": {
+ "./package.json": "./package.json",
".": {
"import": {
"types": "./lib/typescript/module/src/index.d.ts",
Link to repro
https://github.com/oblador/react-native-vector-icons/tree/monorepo in about 20 mins haven't commited yet you'll need to undo the fix in package.json
Environment
System:
OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
CPU: (16) x64 AMD Ryzen 7 7840U w/ Radeon 780M Graphics
Memory: 15.90 GB / 30.66 GB
Shell:
version: 5.2.21
path: /bin/bash
Binaries:
Node:
version: 20.17.0
path: ~/.nvm/versions/node/v20.17.0/bin/node
Yarn:
version: 4.2.2
path: ~/.nvm/versions/node/v20.17.0/bin/yarn
npm:
version: 10.8.2
path: ~/.nvm/versions/node/v20.17.0/bin/npm
Watchman: Not Found
SDKs:
Android SDK:
API Levels:
- "29"
- "31"
- "32"
- "33"
- "34"
Build Tools:
- 28.0.3
- 29.0.2
- 29.0.3
- 30.0.2
- 30.0.3
- 31.0.0
- 31.0.0
- 32.1.0
- 33.0.0
- 33.0.0
- 33.0.1
- 34.0.0
- 34.0.0
- 35.0.0
System Images:
- android-31 | Intel x86_64 Atom
- android-31 | Google APIs Intel x86_64 Atom
- android-33 | Google APIs Intel x86_64 Atom
- android-33 | Google Play Intel x86 Atom_64
- android-34 | Google Play Intel x86_64 Atom
Android NDK: Not Found
IDEs:
Android Studio: AI-223.8836.35.2231.10811636
Languages:
Java:
version: 11.0.24
path: /usr/bin/javac
Ruby:
version: 3.2.3
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react: Not Found
react-native: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: false
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: false