nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.77k stars 2.37k forks source link

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

Open jsancho opened 8 months ago

jsancho commented 8 months ago

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/detox@18.0.8

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/detox@20.19.1/node_modules/detox: Running postinstall script, failed in 71ms
.../detox@20.19.1/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/detox@20.19.1/node_modules/detox/src/utils/rn-consts/rn-consts.js
│ - /home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/detox@20.19.1/node_modules/detox/scripts/updateGradle.js
│ - /home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/detox@20.19.1/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/detox@20.19.1/node_modules/detox/src/utils/rn-consts/rn-consts.js:2:23)
│     at Object.<anonymous> (/home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/detox@20.19.1/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/detox@20.19.1/node_modules/detox/src/utils/rn-consts/rn-consts.js',
│     '/home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/detox@20.19.1/node_modules/detox/scripts/updateGradle.js',
│     '/home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/detox@20.19.1/node_modules/detox/scripts/postinstall.js'
│   ]
│ }
│ Node.js v18.17.0
└─ Failed in 71ms at /home/vehnet/source/pnpm-nrwl/node_modules/.pnpm/detox@20.19.1/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/detox@18.0.8
  3. package installation will fail with the following error
.../detox@20.19.1/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/nx@18.0.8/node_modules/nx postinstall$ node ./bin/post-install
.../.pnpm/nx@18.0.8/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/detox@18.0.8

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

Additional Information

No response

xiongemi commented 6 months ago

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

github-actions[bot] commented 1 week ago

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! 🙏