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

create-nx-workspace fails creating the react-native preset when using pnpm #22312

Closed
2 of 4 tasks
jsancho opened this issue Mar 14, 2024 · 2 comments · Fixed by #29122
Closed
2 of 4 tasks

create-nx-workspace fails creating the react-native preset when using pnpm #22312

jsancho opened this issue Mar 14, 2024 · 2 comments · Fixed by #29122
Assignees
Labels
scope: react-native Issues relating to React Native stale type: bug

Comments

@jsancho
Copy link

jsancho commented Mar 14, 2024

Current Behavior

OS: Windows 11 / Ubuntu 20.04.4 LTS
pnpm: 8.15.4

Using this command pnpx create-nx-workspace pnpm-nrwl --preset=react-native --appName=mobile --nxCloud=skip
I eventually get a Failed to create a workspace error.

When looking at the error log, this is the command that fails

NX Command failed: pnpm add -D @nx/[email protected]

I've opened the workspace folder and attempted to install the dependency manually, but it fails with the following error

Progress: resolved 774, reused 765, downloaded 0, added 68, done
node_modules/.pnpm/[email protected]/node_modules/detox: Running postinstall script, failed in 71ms
.../[email protected]/node_modules/detox postinstall$ node scripts/postinstall.js
│ node:internal/modules/cjs/loader:1080
│   throw err;
│   ^
│ Error: Cannot find module 'react-native/package.json'
│ Require stack:
│ - /home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/[email protected]/node_modules/detox/src/utils/rn-consts/rn-consts.js
│ - /home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/[email protected]/node_modules/detox/scripts/updateGradle.js
│ - /home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/[email protected]/node_modules/detox/scripts/postinstall.js
│     at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
│     at Module._load (node:internal/modules/cjs/loader:922:27)
│     at Module.require (node:internal/modules/cjs/loader:1143:19)
│     at require (node:internal/modules/cjs/helpers:110:18)
│     at parseRNVersion (/home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/[email protected]/node_modules/detox/src/utils/rn-consts/rn-consts.js:2:23)
│     at Object.<anonymous> (/home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/[email protected]/node_modules/detox/src/utils/rn-consts/rn-consts.js:11:3)
│     at Module._compile (node:internal/modules/cjs/loader:1256:14)
│     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
│     at Module.load (node:internal/modules/cjs/loader:1119:32)
│     at Module._load (node:internal/modules/cjs/loader:960:12) {
│   code: 'MODULE_NOT_FOUND',
│   requireStack: [
│     '/home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/[email protected]/node_modules/detox/src/utils/rn-consts/rn-consts.js',
│     '/home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/[email protected]/node_modules/detox/scripts/updateGradle.js',
│     '/home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/[email protected]/node_modules/detox/scripts/postinstall.js'
│   ]
│ }
│ Node.js v18.17.0
└─ Failed in 71ms at /home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/[email protected]/node_modules/detox

This issue happens on both Windows 11 and Ubuntu 20.04.4 LTS when using the latest version of pnpm 8.15.4
The workspace creation works as expected when using npm.

Expected Behavior

The create-nx-workspace should complete when using it with pnpx so that pnpm can be used as package manager.

GitHub Repo

No response

Steps to Reproduce

  1. pnpx create-nx-workspace pnpm-nrwl --preset=react-native --appName=mobile --nxCloud=skip
  2. open the workspace folder and run pnpm add -D @nx/[email protected]
  3. package installation will fail with the following error
.../[email protected]/node_modules/detox postinstall$ node scripts/postinstall.js
│ node:internal/modules/cjs/loader:1080
│   throw err;
│   ^
│ Error: Cannot find module 'react-native/package.json'

Nx Report

NX   Report complete - copy this into the issue template

Node   : 18.17.0
OS     : win32-x64
pnpm   : 8.15.3

nx                : 18.0.8
@nx/js            : 18.0.8
@nx/jest          : 18.0.8
@nx/linter        : 18.0.8
@nx/eslint        : 18.0.8
@nx/workspace     : 18.0.8
@nx/detox         : 18.0.8
@nx/devkit        : 18.0.8
@nx/react         : 18.0.8
@nx/react-native  : 18.0.8
@nrwl/tao         : 18.0.8
@nx/web           : 18.0.8
typescript        : 5.3.3

Failure Logs

Progress: resolved 1, reused 0, downloaded 0, added 0
Progress: resolved 2, reused 2, downloaded 0, added 0
Progress: resolved 57, reused 40, downloaded 0, added 0
Progress: resolved 105, reused 89, downloaded 2, added 0
Progress: resolved 209, reused 189, downloaded 5, added 0
Progress: resolved 385, reused 359, downloaded 13, added 0
Progress: resolved 639, reused 600, downloaded 14, added 0
Progress: resolved 703, reused 674, downloaded 19, added 0
Packages: +701
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 707, reused 677, downloaded 19, added 106
Progress: resolved 707, reused 677, downloaded 20, added 304
Progress: resolved 707, reused 677, downloaded 20, added 536
Progress: resolved 707, reused 677, downloaded 20, added 695
Progress: resolved 707, reused 677, downloaded 20, added 701, done
.../.pnpm/[email protected]/node_modules/nx postinstall$ node ./bin/post-install
.../.pnpm/[email protected]/node_modules/nx postinstall: Done

devDependencies:
+ @nx/react-native 18.0.8
+ @nx/workspace 18.0.8
+ nx 18.0.8

Done in 16.9s

 NX  Generating @nx/workspace:preset

Fetching prettier...
Fetching @nx/webpack...
Fetching @nx/detox...

 NX   Command failed: pnpm add -D @nx/[email protected]

Pass --verbose to see the stacktrace.


 NX   Workspace creation failed, see above.

Pass --verbose to see the stacktrace.

Package Manager Version

pnpm 8.15.4

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@FrozenPandaz FrozenPandaz added the scope: react-native Issues relating to React Native label Mar 15, 2024
@xiongemi
Copy link
Collaborator

i seems fine on macos with version 19.0.4. I will try again on windows.

Copy link

This issue has been automatically marked as stale because it hasn't had any activity for 6 months.
Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore.
If at this point, this is still an issue, please respond with updated information.
It will be closed in 21 days if no further activity occurs.
Thanks for being a part of the Nx community! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: react-native Issues relating to React Native stale type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants