Skip to content

npx react-native-macos-init expects a project with installed dependencies #2743

@kraenhansen

Description

@kraenhansen

Environment

react-native -v:
20.0.2
npm ls react-native-macos:
MacOSTestApp@0.0.1 /Users/kraen.hansen/Repositories/react-native-node-api/apps/macos-test-app
└── (empty)
node -v:
v22.19.0
npm -v:
10.9.3
yarn --version:
N/A
xcodebuild -version:
Xcode 16.2
Build version 16C5032a

Steps to reproduce the bug

Following the steps https://microsoft.github.io/react-native-windows/docs/rnm-getting-started, while also passing --skip-install to the @react-native-community/cli init call:

  1. npx @react-native-community/cli init MacOSTestApp --skip-install --version 0.78 --directory ./macos-test-app
  2. cd macos-test-app
  3. npx react-native-macos-init

Expected Behavior

I'd expect to either:

  1. init the MacOS app in the newly created app without having to install dependencies, this is needed because I want to do this only once -- or
  2. get a nice error asking me to run npm install before initializing the MacOS part.

Actual Behavior

I get the following error when running the last command:

Reading application name from package.json…
Reading react-native version from node_modules…
Reading react-native-macos version from node_modules…
Latest matching version of react-native-macos for react-native@0.81.4 is react-native-macos@0.79.0.
Installing react-native-macos@^0.79.0-0…
Command failed: npm install --save --silent "react-native-macos@^0.79.0-0" Error: Command failed: npm install --save --silent "react-native-macos@^0.79.0-0"
    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at checkExecSyncError (node:child_process:915:11)
    at execSync (node:child_process:987:15)
    at /Users/kraen.hansen/.npm/_npx/20f1505fae2cef5b/node_modules/react-native-macos-init/lib-commonjs/cli.js:228:42
    at Generator.next (<anonymous>)
    at fulfilled (/Users/kraen.hansen/.npm/_npx/20f1505fae2cef5b/node_modules/react-native-macos-init/lib-commonjs/cli.js:11:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
  status: 1,
  signal: null,
  output: [ null, <Buffer >, <Buffer > ],
  pid: 59058,
  stdout: <Buffer >,
  stderr: <Buffer >
}

Reproducible Demo

N/A

Additional context

Haven't dug more into this, but a workaround exists (running npm install or not passing --skip-install

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions