nx
nx copied to clipboard
React Native - Unable to resolve module for Android on Windows machines
Current Behavior
My co-workers and I are all getting this issue only on Windows machines when starting the Android app. It seems there was an existing issue for this that was closed as completed https://github.com/nrwl/nx-react-native/issues/23 but now appears to be back.
error: ReferenceError: SHA-1 for file D:\Business\Development\Code\node_modules\rxjs\dist\cjs\internal\observable.js (D:\Business\Development\Code\node_modules\rxjs\dist\cjs\inter
nal\observable.js) is not computed.
Potential causes:
1) You have symlinks in your project - watchman does not follow symlinks.
2) Check `blockList` in your metro.config.js and make sure it isn't excluding the file path.
at DependencyGraph.getSha1 (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\node-haste\DependencyGraph.js:191:13)
at Transformer.transformFile (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\DeltaBundler\Transformer.js:104:23)
at Bundler.transformFile (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\Bundler.js:57:30)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.transform (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\lib\transformHelpers.js:101:12)
at async processModule (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\DeltaBundler\traverseDependencies.js:137:18)
at async addDependency (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\DeltaBundler\traverseDependencies.js:230:18)
at async Promise.all (index 1)
at async processModule (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\DeltaBundler\traverseDependencies.js:198:5)
at async addDependency (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\DeltaBundler\traverseDependencies.js:230:18)
info Reloading app...
BUNDLE src/main.tsx
error: Error: Unable to resolve module ../Observable from D:\Business\Development\Code\node_modules\rxjs\dist\cjs\internal\observable\ConnectableObservable.js: ../Observable could not be found with
in the project or in these directories:
node_modules
17 | Object.defineProperty(exports, "__esModule", { value: true });
18 | exports.ConnectableObservable = void 0;
> 19 | var Observable_1 = require("../Observable");
| ^
20 | var Subscription_1 = require("../Subscription");
21 | var refCount_1 = require("../operators/refCount");
22 | var OperatorSubscriber_1 = require("../operators/OperatorSubscriber");
at ModuleResolver.resolveDependency (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:158
:15)
at DependencyGraph.resolveDependency (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\node-haste\DependencyGraph.js:231:43)
at Object.resolve (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\lib\transformHelpers.js:129:24)
at resolve (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\DeltaBundler\traverseDependencies.js:396:33)
at D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\DeltaBundler\traverseDependencies.js:412:26
at Array.reduce (<anonymous>)
at resolveDependencies (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\DeltaBundler\traverseDependencies.js:411:33)
at processModule (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\DeltaBundler\traverseDependencies.js:140:31)
at async addDependency (D:\Business\Development\Code\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\DeltaBundler\traverseDependencies.js:230:18)
at async Promise.all (index 1)
Steps to Reproduce
Seems to be caused by the rxjs library
Environment
Node : 16.14.2
OS : win32 x64
yarn : 1.22.18
nx : 14.4.2
react-native: 0.68.2
@react-native-community/cli: 7.0.3
@react-native-community/cli-debugger-ui: 7.0.3
@react-native-community/cli-platform-android: 7.0.1
@react-native-community/cli-platform-ios: 7.0.1
metro: 0.71.2
metro-core: 0.71.2
metro-react-native-babel-preset: 0.71.2
metro-resolver: 0.71.2
@nrwl/cypress : 14.4.2
@nrwl/detox : 14.4.2
@nrwl/devkit : 14.4.2
@nrwl/eslint-plugin-nx : 14.4.2
@nrwl/express : 14.4.2
@nrwl/jest : 14.4.2
@nrwl/js : 14.4.2
@nrwl/linter : 14.4.2
@nrwl/next : 14.4.2
@nrwl/node : 14.4.2
@nrwl/nx-cloud : 14.0.8
@nrwl/react : 14.4.2
@nrwl/react-native : 14.4.2
@nrwl/storybook : 14.4.2
@nrwl/web : 14.4.2
@nrwl/workspace : 14.4.2
typescript : 4.7.4
---------------------------------------
Community plugins:
@simondotm/nx-firebase: 0.3.3
Hi @enchorb, I'm having the exact issue on my end as well.
Hey! Thanks for reporting this issue.
I don't really understand the problem based on the information you provided.
I tried the default react-native android app by running npx create-nx-workspace --preset=react-native
, and it works fine on my windows machine.
Can you provide a small repro?
Hi all together, I'm having the exact issue on my end as well.
This only happens in release build (on windows).
The debug build (npx nx build-android --debug
) is successful.
I am also able to run the android app (npx nx run-android
), because it is probably using the debug build.
Hey all, I'm having this issue with a project created using @nrwl/expo:app
too.
I'm also using rxjs in my project.
I have a Nx library that depends on rxjs. I can replicate this consistently on a new project by using my Nx library project with rxjs in the new RN project.
maybe it is related to react native 0.69? because now both @nrwl/react-native and @nrwl/expo use react native 0.69, which uses new architecture and hermes? From its website, it says: "Note that users on the New Architecture on Android will need to build Hermes from source. For building Hermes from source, Windows users will need to additionally follow these steps."
@xiongemi I only updated to version 0.68.2 because version 0.69 was not yet available ("@nrwl/[email protected]
).
But with the release of @nrwl/[email protected]
i will try the upgrade to 0.69.
I just tested this, and it seems to be fixed with react-native
being updated to 0.69
. Please test with the latest version of Nx and let us know.
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.