Mac下Dart环境安装

2019-06-15  本文已影响0人  imkobedroid

安装HomeBrew

在终端运行命令安装:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装dart

只针对开发版进行安装

 brew tap dart-lang/dart
 brew install dart --devel

这下载过程中可能会出现下面这种问题:

Error: An exception occurred within a child process:
DownloadError: Failed to download resource "dart"
Download failed: https://storage.googleapis.com/dart-archive/channels/stable/release/2.0.0/sdk/dartsdk-macos-x64-release.zip

这一般是被墙了,,但是可以通过下载地址进行手动下载,下载后将其解压出来,例如我解压出来的地址这样的:

/usr/local/Homebrew/dart-sdk

在IDEA中创建工程的时候将dart的地址指向他就行了,这样就可以使用dart了

hello world

运行代码:

void main(){
  print("Hello World!");
}

结果:

/usr/local/Homebrew/dart-sdk/bin/dart --enable-vm-service:51494 /Users/toushihiroshi/Desktop/Dart/dart/chapter1.dart
Observatory listening on http://[::1]:51494/O-vlLQU_Dgk=/

Hello World!

Process finished with exit code 0

环境变量的配置

#Dart的配置
export DART_HOME=/usr/local/Homebrew/dart-sdk/bin
export PATH="${DART_HOME}:${PATH}"

环境搭建完毕!

上一篇下一篇

猜你喜欢

热点阅读