Repository navigation
npm install fails when "Extension Pack for Java" is enabled in vscode/cursor #66662
Copy link
Copy link
Closed
Labels
BugSomething is broken. Auto assigns a BugZero manager.Something is broken. Auto assigns a BugZero manager.DailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributorsApply this label when an issue is open to proposals by contributorsReviewingHas a PR in reviewHas a PR in review
Description
This is a build issue. It does not affect users, but may prevent contributors from being able to run and test the code.
Version Number:
Reproducible in staging?:
Reproducible in production?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @chuckdries
Slack conversation (hyperlinked to channel name): #expensify-open-source
Action Performed:
- Checkout App repo
- open in Cursor
- install https://marketplace.cursorapi.com/items/?itemName=vscjava.vscode-java-pack extension (or vscode equivalent) and enable it
- attempt to run
npm install
Expected Result:
Install succeeds and exits
Actual Result:
Install fails on patch-package
**ERROR** Failed to apply patch for package react-native-vision-camera at path
node_modules/react-native-vision-camera
This error was caused because patch-package cannot apply the following patch file:
patches/react-native-vision-camera+4.6.1.patch
Try removing node_modules and trying again. If that doesn't work, maybe there was
an accidental change made to the patch file? Try recreating it by manually
editing the appropriate files and running:
patch-package react-native-vision-camera
If that doesn't work, then it's a bug in patch-package, so please submit a bug
report. Thanks!
https://github.com/ds300/patch-package/issues
- Failed to apply patch file: /Users/chuckdries/Expensidev/App/patches/tmp-patches-uYN/react-native-vision-camera+4.6.1.patch
---
patch-package finished with 2 error(s).
💥 patch-package failed
npm error code 1
npm error path /Users/chuckdries/Expensidev/App
npm error command failed
npm error command sh -c ./scripts/postInstall.sh
npm error A complete log of this run can be found in: /Users/chuckdries/.npm/_logs/2025-07-16T22_12_46_920Z-debug-0.log
Dependency installaton failed. Check if package-lock.json exists
If you run npm install another time, it'll also fail for @onfido/react-native-sdk
Workaround:
N/A, tooling issue does not affect users
Platforms:
N/A, tooling issue does not affect users
Issue Owner
Current Issue Owner: @marcaaronReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugSomething is broken. Auto assigns a BugZero manager.Something is broken. Auto assigns a BugZero manager.DailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributorsApply this label when an issue is open to proposals by contributorsReviewingHas a PR in reviewHas a PR in review
Activity
melvin-bot commentedon Jul 17, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ikevin127 (
External)melvin-bot commentedon Jul 17, 2025
Triggered auto assignment to @isabelastisser (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.TaduJR commentedon Jul 18, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
npm installfails when the "Extension Pack for Java" is enabled in VS Code/Cursor. Developers are forced to either disable Java extensions entirely or manually work around the installation failures, disrupting their development workflow and preventing them from using Java tooling alongside the React Native project.What is the root cause of that problem?
The Java extensions in VS Code/Cursor automatically scan and process files in
node_modulesduring package installation. This creates a timing and file state conflict withpatch-package:node_modulesin their original statenode_modulesand modify/create metadata files for Java/Android components (especially in React Native packages likereact-native-vision-camera)patch-packagedetects file differences and refuses to apply patches, causing the entire installation to failThis happens because
patch-packageuses binary/checksum comparisons and expects pristine file states, while Java extensions continuously modify files for indexing and IntelliSense purposes.What changes do you think we should make in order to solve the problem?
Primary Solution: Configure VS Code Workspace Settings
Create a
.vscode/settings.jsonfile with the following configurations:{ "java.project.resourceFilters": ["node_modules/**", ".git/**"], "java.import.exclusions": ["**/node_modules/**", "**/.git/**"], "java.project.sourcePaths": [], "files.exclude": { "**/node_modules/**": true }, "search.exclude": { "**/node_modules/**": true } }Benefits of this approach:
node_modulesdirectoriesWhat specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Test npm install with Java extensions simulation
patch-packagecan still apply patches successfullyTest workspace settings effectiveness
.vscode/settings.jsonconfigurations properly excludenode_modulesTest patch application robustness
applyPatches.shscript can handle these gracefullyWhat alternative solutions did you explore?
Complete Java Extension Disabling
Modifying patch-package Timing
Using npm ci instead of npm install
Result: https://www.loom.com/share/75ab9ef0873b480abb269546e9387325
ikevin127 commentedon Jul 19, 2025
@chuckdries Followed steps to the letter (using Cursor, installed the exact same extension), then ran both
npm installandnpm ciand I can't reproduce the issue at all, I always get success on patch-package:+ 🎉 patch-package succeeded without errors or warnings@TaduJR Thanks for the proposal. Regarding the suggestion to add
.vscode/settings.jsonpublicly to the repository, basically unhidding the.vscodeeditor settings from.gitignore, IMO we shouldn't do this as it pretains to the user's local settings which should not be enforced for everybody.This shouldn't be an issue IMO, as editor specific issues should be fixed locally by the people experiencing them, especially with very specific edge cases like using a paid code editor and having a specific extension installed. I don't see such issues as a problem caused by the Expensify/App repo, hence requiring an issue to fix the problem for everybody (since most don't use the same code editor / extensions causing the issue).
At most, I'd post a public message in Slack to let everybody know that in case they are experiencing issues with patch-package failing, it might be due to their code editor / extensions (since 99% of the people are not experiencing the issue) and could most likely fix the issue by adjusting their local
.vscode/settings.json.🎀👀🎀 C+ reviewed
melvin-bot commentedon Jul 19, 2025
Triggered auto assignment to @marcaaron, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
TaduJR commentedon Jul 20, 2025
Awesome @ikevin127
That's great solution since most people are not experiencing them.
Thank you so much for your feedback.
chuckdries commentedon Jul 21, 2025
Huh, I can't reproduce the issue anymore. Oh well I guess