react-native-community / cli

The React Native Community CLI - command line tools to help you build RN apps
MIT License
2.41k stars 905 forks source link

fix(cli): fix `ENOWORKSPACES` when running any command on latest npm #2457

Closed tido64 closed 4 months ago

tido64 commented 4 months ago

Summary:

Commands are failing on npm 10.7.0 (and Node 20.15.1) when inside a monorepo. Example when building Android:

Error executing command '[node, npm error code ENOWORKSPACES
npm error This command does not support workspaces.

npm error A complete log of this run can be found in: ~/.npm/_logs/2024-07-15T08_41_45_432Z-debug-0.log
/~/node_modules/@react-native-community/cli/build/bin.js, config, --platform, android]': Command '[node, npm error code ENOWORKSPACES
npm error This command does not support workspaces.

npm error A complete log of this run can be found in: ~/.npm/_logs/2024-07-15T08_41_45_432Z-debug-0.log
/~/node_modules/@react-native-community/cli/build/bin.js, config, --platform, android]' failed with exit code 1.

The culprit seems to be this command, which is called unconditionally when importing npm.ts:

% npm config get registry
npm error code ENOWORKSPACES
npm error This command does not support workspaces.

Test Plan:

node -p 'require("@react-native-community/cli").bin'

Checklist