microsoft / react-native-macos

A framework for building native macOS apps with React.
https://microsoft.github.io/react-native-windows/
MIT License
3.46k stars 132 forks source link

Unable to setup using npx react-native-macos-init #2152

Closed adithyan closed 1 week ago

adithyan commented 1 month ago

Problem Description

I'm trying to follow the steps from the Get Started with macOS, but I got stuck with the macos init Here is the output from the terminal

➜  trial_app git:(master) ✗ npx react-native-macos-init  
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.71.0 is react-native-macos@0.71.36.
Installing react-native-macos@^0.71.0-0…
Command failed: yarn add -s "react-native-macos@^0.71.0-0" Error: Command failed: yarn add -s "react-native-macos@^0.71.0-0"
    at checkExecSyncError (node:child_process:890:11)
    at Object.execSync (node:child_process:962:15)
    at Object.<anonymous> (/Users/x/.npm/_npx/20f1505fae2cef5b/node_modules/react-native-macos-init/lib-commonjs/cli.js:247:29)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/x/.npm/_npx/20f1505fae2cef5b/node_modules/react-native-macos-init/lib-commonjs/cli.js:10:58)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at process.processImmediate (node:internal/timers:449:9) {
  status: 1,
  signal: null,
  output: [
    null,
    <Buffer 1b 5b 33 31 6d 1b 5b 31 6d 55 6e 6b 6e 6f 77 6e 20 53 79 6e 74 61 78 20 45 72 72 6f 72 1b 5b 32 32 6d 1b 5b 33 39 6d 3a 20 55 6e 73 75 70 70 6f 72 74 ... 183 more bytes>,
    <Buffer >
  ],
  pid: 68213,
  stdout: <Buffer 1b 5b 33 31 6d 1b 5b 31 6d 55 6e 6b 6e 6f 77 6e 20 53 79 6e 74 61 78 20 45 72 72 6f 72 1b 5b 32 32 6d 1b 5b 33 39 6d 3a 20 55 6e 73 75 70 70 6f 72 74 ... 183 more bytes>,
  stderr: <Buffer >
}

Nodejs version : v20.11.1

Steps To Reproduce

npx react-native@latest init trial_app --version 0.71.0

cd trial_app

npx react-native-macos-init

Expected Results

No response

CLI version

10.0.0

Environment

System:
    OS: macOS 13.6.4
    CPU: (8) arm64 Apple M1 Pro
    Memory: 74.48 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - /usr/local/bin/node
    Yarn: 3.6.4 - /opt/homebrew/bin/yarn
    npm: 10.8.1 - /opt/homebrew/bin/npm
    Watchman: 2024.07.15.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: Not Found
  SDKs:
    iOS SDK:
      Platforms: DriverKit 23.2, iOS 17.2, macOS 14.2, tvOS 17.2, visionOS 1.0, watchOS 10.2
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 15.2/15C500b - /usr/bin/xcodebuild
  Languages:
    Java: 17.0.12 - /Users/x/.jenv/versions/17.0.10/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.0 => 0.71.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Community Modules

No response

Target Platform Version

None

Target Device(s)

No response

Visual Studio Version

None

Build Configuration

None

Snack, code example, screenshot, or link to a repository

No response

Saadnajmi commented 1 month ago

Hi, we're aware of this issue, and working on fixing it with the next React Native macOS release. Meanwhile you can locally patch with the fix here: https://github.com/microsoft/react-native-macos/commit/b15e16827f5cfc2afb46bfe0d6d95f77ca7f4d9e

Yoha485 commented 2 weeks ago

Patch was not helpful for me Are there any other solutions to that problem? Those are my logs after patch

npx react-native-macos-init
Running Patched version of react-native-macos-init
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.71.19 is react-native-macos@0.71.36.
Installing react-native-macos@^0.71.0-0…
Command failed: yarn add --silent "react-native-macos@^0.71.0-0" Error: Command failed: yarn add --silent "react-native-macos@^0.71.0-0"
    at checkExecSyncError (node:child_process:890:11)
    at Object.execSync (node:child_process:962:15)
    at Object.<anonymous> (/Users/antonmorozov/Desktop/Freelance/GlobalObsidianSwitcher/node_modules/react-native-macos-init/lib-commonjs/cli.js:247:29)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/antonmorozov/Desktop/Freelance/GlobalObsidianSwitcher/node_modules/react-native-macos-init/lib-commonjs/cli.js:10:58)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at process.processImmediate (node:internal/timers:447:9) {
  status: 1,
  signal: null,
  output: [
    null,
    <Buffer 1b 5b 33 31 6d 1b 5b 31 6d 55 73 61 67 65 20 45 72 72 6f 72 1b 5b 32 32 6d 1b 5b 33 39 6d 3a 20 54 68 69 73 20 63 6f 6d 6d 61 6e 64 20 63 61 6e 20 6f ... 368 more bytes>,
    <Buffer >
  ],
  pid: 19208,
  stdout: <Buffer 1b 5b 33 31 6d 1b 5b 31 6d 55 73 61 67 65 20 45 72 72 6f 72 1b 5b 32 32 6d 1b 5b 33 39 6d 3a 20 54 68 69 73 20 63 6f 6d 6d 61 6e 64 20 63 61 6e 20 6f ... 368 more bytes>,
  stderr: <Buffer >
}
Yoha485 commented 2 weeks ago

Running cli comand like so npx react-native-macos-init --verbose=true Helped to overcome the issue above. Probably because --silent flag is only present in yarn install but not in yarn add But now I get another error

npx react-native-macos-init --verbose=true
Running Patched version of react-native-macos-init
Using verbose: true
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.71.19 is react-native-macos@0.71.36.
Installing react-native-macos@^0.71.0-0…
➤ YN0000: ┌ Resolution step
➤ YN0002: │ react-native-codegen@npm:0.71.6 doesn't provide @babel/preset-env (p051ae), requested by jscodeshift
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed in 0s 712ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ @react-native-community/cli-platform-ios@npm:10.2.4 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ @react-native-community/cli@npm:10.2.4 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ react-native-macos@npm:0.71.36 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed in 0s 914ms
➤ YN0000: Done with warnings in 1s 896ms
react-native-macos@^0.71.0-0 successfully installed!

removed 78 packages, changed 1 package, and audited 981 packages in 4s

143 packages are looking for funding
  run `npm fund` for details

13 vulnerabilities (7 moderate, 6 high)

To address issues that do not require attention, run:
  npm audit fix

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
new macos/Podfile
new macos/.gitignore
new macos/GlobalObsidianSwitcher-macOS/AppDelegate.h
new macos/GlobalObsidianSwitcher-macOS/AppDelegate.mm
new macos/GlobalObsidianSwitcher-macOS/Assets.xcassets/AppIcon.appiconset/Contents.json
new macos/GlobalObsidianSwitcher-macOS/Assets.xcassets/Contents.json
new macos/GlobalObsidianSwitcher-macOS/Base.lproj/Main.storyboard
new macos/GlobalObsidianSwitcher-macOS/GlobalObsidianSwitcher.entitlements
new macos/GlobalObsidianSwitcher-macOS/Info.plist
new macos/GlobalObsidianSwitcher-macOS/main.m
new macos/GlobalObsidianSwitcher.xcodeproj/project.pbxproj
new macos/GlobalObsidianSwitcher.xcodeproj/xcshareddata/xcschemes/GlobalObsidianSwitcher-macOS.xcscheme
Scanning for pods...
1.15.2
> pod install

[!] Invalid `Podfile` file: cannot load such file -- /Users/antonmorozov/Desktop/Freelance/GlobalObsidianSwitcher/node_modules/node_modules/react-native-macos/scripts/react_native_pods.

 #  from /Users/antonmorozov/Desktop/Freelance/GlobalObsidianSwitcher/node_modules/macos/Podfile:1
 #  -------------------------------------------
 >  require_relative '../node_modules/react-native-macos/scripts/react_native_pods'
 #  require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
 #  -------------------------------------------
Couldn't install Pods. Updating the Pods project and trying again...
> pod install --repo-update

[!] Invalid `Podfile` file: cannot load such file -- /Users/antonmorozov/Desktop/Freelance/GlobalObsidianSwitcher/node_modules/node_modules/react-native-macos/scripts/react_native_pods.

 #  from /Users/antonmorozov/Desktop/Freelance/GlobalObsidianSwitcher/node_modules/macos/Podfile:1
 #  -------------------------------------------
 >  require_relative '../node_modules/react-native-macos/scripts/react_native_pods'
 #  require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
 #  -------------------------------------------
Couldn't install Pods. Updating the Pods project and trying again...
Command `pod install` failed.
└─ Cause: Invalid `Podfile` file: cannot load such file -- /Users/antonmorozov/Desktop/Freelance/GlobalObsidianSwitcher/node_modules/node_modules/react-native-macos/scripts/react_native_pods.

 #  from /Users/antonmorozov/Desktop/Freelance/GlobalObsidianSwitcher/node_modules/macos/Podfile:1
 #  -------------------------------------------
 >  require_relative '../node_modules/react-native-macos/scripts/react_native_pods'
 #  require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
 #  -------------------------------------------

pod install --repo-update --ansi exited with non-zero code: 1
Command failed: npx  pod-install --non-interactive  Error: Command failed: npx  pod-install --non-interactive 
    at checkExecSyncError (node:child_process:890:11)
    at Object.execSync (node:child_process:962:15)
    at installPods (/Users/antonmorozov/Desktop/Freelance/GlobalObsidianSwitcher/node_modules/react-native-macos/local-cli/generator-macos/index.js:131:16)
    at generateMacOS (/Users/antonmorozov/Desktop/Freelance/GlobalObsidianSwitcher/node_modules/react-native-macos/local-cli/generate-macos.js:33:3)
    at Object.<anonymous> (/Users/antonmorozov/Desktop/Freelance/GlobalObsidianSwitcher/node_modules/react-native-macos-init/lib-commonjs/cli.js:255:9)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/antonmorozov/Desktop/Freelance/GlobalObsidianSwitcher/node_modules/react-native-macos-init/lib-commonjs/cli.js:10:58)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at process.processImmediate (node:internal/timers:447:9) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 22462,
  stdout: null,
  stderr: null
}
Saadnajmi commented 2 weeks ago

Just to give an update, I am looking at getting this fixed and published. I apologize for the delay.

Saadnajmi commented 1 week ago

Fixed with version 2.1.2