Skip to content
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

React Native, PNPM Cannot resolve OS #15763

Closed
Singloo opened this issue Mar 20, 2023 · 1 comment · Fixed by #15956
Closed

React Native, PNPM Cannot resolve OS #15763

Singloo opened this issue Mar 20, 2023 · 1 comment · Fixed by #15956
Labels
outdated scope: react-native Issues relating to React Native type: bug

Comments

@Singloo
Copy link
Contributor

Singloo commented Mar 20, 2023

Current Behavior

After adding styled-components, metro failed to bundle.
Seems that nx metro resolver has problems with nodejs builtin modules?

Expected Behavior

Should work properly

GitHub Repo

https://github.com/Singloo/nx-react-native-test

Steps to Reproduce

  1. git clone git@github.com:Singloo/nx-react-native-test.git
  2. pnpm install
  3. pnpm nx run-ios mobile

Nx Report

Node : 18.15.0
   OS   : darwin arm64
   pnpm : 7.30.0
   
   nx                      : 15.8.6
   @nrwl/js                : 15.8.6
   @nrwl/jest              : 15.8.6
   @nrwl/linter            : 15.8.6
   @nrwl/workspace         : 15.8.6
   @nrwl/cli               : 15.8.6
   @nrwl/detox             : 15.8.6
   @nrwl/devkit            : 15.8.6
   @nrwl/eslint-plugin-nx  : 15.8.6
   @nrwl/react             : 15.8.6
   @nrwl/react-native      : 15.8.6
   @nrwl/tao               : 15.8.6
   typescript              : 4.9.5

Failure Logs

get full logs here

[Nx] Resolving: os
[Nx] Unable to resolve with default resolveRequest: os
[Nx] Unable to resolve with default Metro resolver: os
[Nx] Failed to resolve os
[Nx] The following tsconfig paths was used:
:{}
[Nx] Unable to resolve with default PNPM resolver: os
 BUNDLE  src/main.tsx 

error: Error: Cannot resolve os
    at /Users/origami/Desktop/projects/nx-react-native-test/node_modules/.pnpm/@nrwl+react-native@15.8.6_kdz4p2zz4cnarrgrfqokqonxqy/node_modules/@nrwl/react-native/plugins/metro-resolver.js:31:15
    at Object.resolve (/Users/origami/Desktop/projects/nx-react-native-test/node_modules/.pnpm/@react-native-community+cli-plugin-metro@10.2.0/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-resolver/src/resolve.js:27:12)
    at ModuleResolver.resolveDependency (/Users/origami/Desktop/projects/nx-react-native-test/node_modules/.pnpm/@react-native-community+cli-plugin-metro@10.2.0/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:111:31)
    at DependencyGraph.resolveDependency (/Users/origami/Desktop/projects/nx-react-native-test/node_modules/.pnpm/@react-native-community+cli-plugin-metro@10.2.0/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/node-haste/DependencyGraph.js:260:43)
    at Object.resolve (/Users/origami/Desktop/projects/nx-react-native-test/node_modules/.pnpm/@react-native-community+cli-plugin-metro@10.2.0/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/lib/transformHelpers.js:177:21)
    at Graph._resolveDependencies (/Users/origami/Desktop/projects/nx-react-native-test/node_modules/.pnpm/@react-native-community+cli-plugin-metro@10.2.0/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/DeltaBundler/Graph.js:432:35)
    at Graph._processModule (/Users/origami/Desktop/projects/nx-react-native-test/node_modules/.pnpm/@react-native-community+cli-plugin-metro@10.2.0/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/DeltaBundler/Graph.js:218:38)
    at async Graph._addDependency (/Users/origami/Desktop/projects/nx-react-native-test/node_modules/.pnpm/@react-native-community+cli-plugin-metro@10.2.0/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/DeltaBundler/Graph.js:314:20)
    at async Promise.all (index 5)
    at async Graph._processModule (/Users/origami/Desktop/projects/nx-react-native-test/node_modules/.pnpm/@react-native-community+cli-plugin-metro@10.2.0/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/DeltaBundler/Graph.js:263:5)

Additional Information

No response

@AgentEnder AgentEnder added the scope: react-native Issues relating to React Native label Mar 20, 2023
Singloo added a commit to Singloo/nx that referenced this issue Mar 29, 2023
Sometimes resolver looks for wrong entry file. Add mainFields options solved this problem. Option
value respects to the default value of metro option `resolverMainFields`

closed nrwl#15763, nrwl#9743
Singloo added a commit to Singloo/nx that referenced this issue Mar 29, 2023
To fix the issue: sometimes resolver look for wrong entry file

closed nrwl#9743, nrwl#15763
Singloo added a commit to Singloo/nx that referenced this issue Mar 29, 2023
Singloo added a commit to Singloo/nx that referenced this issue Mar 31, 2023
@github-actions
Copy link

github-actions bot commented May 1, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: react-native Issues relating to React Native type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants