-
Notifications
You must be signed in to change notification settings - Fork 25k
Fix exception in codegen when dependency is not found #54665
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 tasks
|
@cortinico has imported this pull request. If you are a Meta employee, you can view this in D87872496. |
|
@cortinico merged this pull request in 20550c4. |
react-native-bot
pushed a commit
that referenced
this pull request
Dec 2, 2025
Summary: Fixed an `ENOENT` exception when a dependency does not export `package.json`, and your repo is set up as a monorepo using pnpm. > [!NOTE] > > This does not fix the actual search algorithm. We shouldn't be using `require.main.paths` here because it does not point to the correct starting point, the project root. > > This change only fixes the case where we cannot find `package.json` at all. ## Changelog: [GENERAL] [FIXED] - Fixed an `ENOENT` exception when a dependency does not export `package.json`, and your repo is set up as a monorepo using pnpm Pull Request resolved: #54665 Test Plan: **Before:** ``` % node node_modules/react-native/scripts/generate-codegen-artifacts.js -p . -o ios -t ios [Codegen] Analyzing package.json [Codegen] Could not find generated autolinking output at: /~/packages/app/example/ios/build/generated/autolinking/autolinking.json [Codegen] Searching for codegen-enabled libraries in the app. [Codegen] The "codegenConfig" field is not defined in package.json. Assuming there is nothing to generate at the app level. [Codegen] Could not find generated autolinking output at: /~/packages/app/example/ios/build/generated/autolinking/autolinking.json [Codegen] Searching for codegen-enabled libraries in the project dependencies. [Codegen] Found react-native-webapis/web-storage [Codegen] Found react-native [Codegen] Found react-native-safe-area-context Trying to find `package.json` for `webdriverio` in [ '/~/node_modules/.store/react-native-virtual-a5dea7d647/package/scripts/node_modules', '/~/node_modules/.store/react-native-virtual-a5dea7d647/package/node_modules', '/~/node_modules/.store/react-native-virtual-a5dea7d647/node_modules', '/~/node_modules/.store/node_modules', '/~/node_modules', '/node_modules' ] [Codegen] Error: ENOENT: no such file or directory, open '' [Codegen] Done. ``` **After:** ``` % node node_modules/react-native/scripts/generate-codegen-artifacts.js -p . -o ios -t ios [Codegen] Analyzing package.json [Codegen] Could not find generated autolinking output at: /~/packages/app/example/ios/build/generated/autolinking/autolinking.json [Codegen] Searching for codegen-enabled libraries in the app. [Codegen] The "codegenConfig" field is not defined in package.json. Assuming there is nothing to generate at the app level. [Codegen] Could not find generated autolinking output at: /~/packages/app/example/ios/build/generated/autolinking/autolinking.json [Codegen] Searching for codegen-enabled libraries in the project dependencies. [Codegen] Found react-native-webapis/web-storage [Codegen] Found react-native [Codegen] Found react-native-safe-area-context Trying to find package.json for webdriverio in [ '/~/node_modules/.store/react-native-virtual-a5dea7d647/package/scripts/node_modules', '/~/node_modules/.store/react-native-virtual-a5dea7d647/package/node_modules', '/~/node_modules/.store/react-native-virtual-a5dea7d647/node_modules', '/~/node_modules/.store/node_modules', '/~/node_modules', '/node_modules' ] [Codegen] Searching for codegen-enabled libraries in react-native.config.js [Codegen] Processing RNWWebStorageSpec [Codegen] Searching for podspec in the project dependencies. [Codegen] Supported Apple platforms: ios, macos, visionos for RNWWebStorageSpec [Codegen] Processing FBReactNativeSpec [Codegen] Searching for podspec in the project dependencies. [Codegen] Processing safeareacontext [Codegen] Searching for podspec in the project dependencies. [Codegen] Supported Apple platforms: ios, macos, tvos, visionos for safeareacontext [Codegen] Generating Native Code for RNWWebStorageSpec - ios [Codegen] Generated artifacts: ios/build/generated/ios/ReactCodegen [Codegen] [Codegen - FBReactNativeSpec] Skipping iOS code generation for FBReactNativeSpec as it has been generated already. [Codegen] Generating Native Code for safeareacontext - ios [Codegen] Generated artifacts: ios/build/generated/ios/ReactCodegen [Codegen] Generating RCTThirdPartyComponentsProvider.h [Codegen] Generated artifact: ios/build/generated/ios/ReactCodegen/RCTThirdPartyComponentsProvider.h [Codegen] Generating RCTThirdPartyComponentsProvider.mm [Codegen] Generated artifact: ios/build/generated/ios/ReactCodegen/RCTThirdPartyComponentsProvider.mm [Codegen] Generating RCTModulesProvider.h [Codegen] Generated artifact: ios/build/generated/ios/ReactCodegen/RCTModuleProviders.h [Codegen] Generating RCTModuleProviders.mm [Codegen] Generated artifact: ios/build/generated/ios/ReactCodegen/RCTModuleProviders.mm [Codegen] Generating RCTAppDependencyProvider [Codegen] Generated artifact: ios/build/generated/ios/ReactAppDependencyProvider/RCTAppDependencyProvider.h [Codegen] Generated artifact: ios/build/generated/ios/ReactAppDependencyProvider/RCTAppDependencyProvider.mm [Codegen] Generated podspec: ios/build/generated/ios/ReactAppDependencyProvider/ReactAppDependencyProvider.podspec [Codegen] Generated podspec: ios/build/generated/ios/ReactCodegen/ReactCodegen.podspec [Codegen] Generating Package.swift [Codegen] Generated artifact: ios/build/generated/ios/Package.swift [Codegen] Done. ``` Reviewed By: cipolleschi Differential Revision: D87872496 Pulled By: cortinico fbshipit-source-id: b9da0e1808248cb806a2a8a0ee575566ce027067
Collaborator
|
This pull request was successfully merged by @tido64 in ad5e268 When will my fix make it into a release? | How to file a pick request? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Merged
This PR has been merged.
p: Microsoft
Partner: Microsoft
Partner
Shared with Meta
Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Fixed an
ENOENTexception when a dependency does not exportpackage.json, and your repo is set up as a monorepo using pnpm.Note
This does not fix the actual search algorithm. We shouldn't be using
require.main.pathshere because it does not point to the correct starting point, the project root.This change only fixes the case where we cannot find
package.jsonat all.Changelog:
[GENERAL] [FIXED] - Fixed an
ENOENTexception when a dependency does not exportpackage.json, and your repo is set up as a monorepo using pnpmTest Plan:
Before:
After: