V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
chiaf
V2EX  ›  iDev

M1 上 React-Native 新建项目,编译报错

  •  
  •   chiaf · 2021-04-30 23:55:22 +08:00 · 3174 次点击
    这是一个创建于 1301 天前的主题,其中的信息可能已经有所发展或是发生改变。
    System:
        OS: macOS 11.3
        CPU: (8) arm64 Apple M1
        Memory: 124.86 MB / 16.00 GB
        Shell: 5.8 - /bin/zsh
      Binaries:
        Node: 16.0.0 - /opt/homebrew/bin/node
        Yarn: Not Found
        npm: 7.10.0 - /opt/homebrew/bin/npm
        Watchman: Not Found
      Managers:
        CocoaPods: 1.10.1 - /Users/chia/.rbenv/shims/pod
      SDKs:
        iOS SDK:
          Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
        Android SDK: Not Found
      IDEs:
        Android Studio: Not Found
        Xcode: 12.5/12E262 - /usr/bin/xcodebuild
      Languages:
        Java: Not Found
      npmPackages:
        @react-native-community/cli: Not Found
        react: 17.0.1 => 17.0.1 
        react-native: 0.64.0 => 0.64.0 
        react-native-macos: Not Found
      npmGlobalPackages:
        *react-native*: Not Found
    
    Error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable.
    Command PhaseScriptExecution failed with a nonzero exit code
    

    node 是通过 homebrew 安装的,不知道是不是这个原因,没有安装 nvm 。

    但是在 Inter Mac 上又没有这个问题( node 安装方式一模一样)。难道是 M1 的原因吗?

    5 条回复    2021-05-01 11:40:19 +08:00
    BrettD
        1
    BrettD  
       2021-05-01 00:31:47 +08:00 via iPhone
    node 在 PATH 环境变量里面吗?
    chiaf
        2
    chiaf  
    OP
       2021-05-01 09:28:32 +08:00
    @BrettD 在的
    `npm -g bin`
    /opt/homebrew/bin

    `echo $PATH`
    /Users/chia/.pyenv/shims:
    /Users/chia/.rbenv/shims:
    /Users/chia/.rbenv/bin:
    /opt/homebrew/bin:
    /opt/homebrew/sbin:
    /usr/local/bin:
    /usr/bin:
    /bin:
    /usr/sbin:
    /sbin:
    /Library/Apple/usr/bin
    learningman
        3
    learningman  
       2021-05-01 09:54:28 +08:00 via Android   ❤️ 1
    有可能他用的环境变量和你用的不是一套,手动指定一下吧
    BrettD
        4
    BrettD  
       2021-05-01 10:09:50 +08:00   ❤️ 1
    Intel 架构上的 Homebrew 以前是链接到 /usr/local/bin 的,在 M1 开始 Homebrew 新安装地点是 /opt/homebrew,我猜测有可能因为那个程序的 PATH 变量用的不是你定义的这一套,所以找不到 /opt/homebrew/bin,不过也可能是其他原因
    chiaf
        5
    chiaf  
    OP
       2021-05-01 11:40:19 +08:00
    @learningman
    @BrettD

    手动指定解决了
    sudo ln -s $(which node) /usr/local/bin/node
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5662 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 02:55 · PVG 10:55 · LAX 18:55 · JFK 21:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.