跳到主要内容
备注

如果遇到任何问题,请在Github或论坛上进行反馈。你的反馈非常重要,有助于我们改进!

提示

MoonBit工具链需要git以正确工作, 请在安装MoonBit工具链之前, 确保已经安装git

VS Code MoonBit 插件

为了提供更佳的开发体验,你可以在 VS Code Marketplace 中安装 MoonBit 插件。此插件为 MoonBit 提供了丰富的开发环境,包括语法高亮、代码完成等功能。

步骤

第 1 步: 安装最新版本的 VS Code。

第 2 步: 点击左侧的“扩展”,搜索“MoonBit”并安装 VS Code MoonBit 扩展。

Untitled

Untitled

第 3 步: 按下shift+cmd+p快捷键(mac快捷键,windows和linux快捷键是ctrl+shift+p),输入 MoonBit:install latest moonbit toolchain,随后会出现提示框,点击“yes”,等待程序下载完成。

Untitled

第 4 步: 下载完成后,重启vscode让PATH环境变量生效。

第 5 步: 点击terminal,输入moon new hello ; code hello以创建并打开新项目。

第 6 步: 项目启动后,再次打开terminal,输入moon run src/main命令,即可开始执行代码。

MoonBit CLI 工具

如果你想下载 MoonBit,请在终端中执行以下指令,并按照屏幕提示进行操作。

curl -fsSL https://cli.moonbitlang.cn/install/unix.sh | bash

命令行工具是创建和管理 MoonBit 项目所必需的。要查看使用说明,请使用 moon help 命令。

$ moon help
Moonbit's build system

Usage: moon <COMMAND>

Commands:
  build     Build the current package
  check     Check the current package, but don't build object files
  run       Run WebAssembly module
  clean     Remove the target directory
  new       Create a new moonbit package
  bench     Generate build matrix for benchmarking
  fmt       Format moonbit
  version   Print version info and exit
  test      Run the tests
  login     Log in to your account
  register  Register an account on mooncakes.io
  publish   Publish the current package
  add       Add a new dependency
  remove    Remove a dependency
  tree      Display the dependency tree
  update    Update index
  doc       Generate documentation
  install   Install dependencies
  help      Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

验证二进制文件

我们提供含有下载二进制文件以及压缩包的SHA校验和的 .sha256 文件。

使用curl(或者Invoke-WebRequest)下载.sha256文件:

curl -O -L https://cli.moonbitlang.cn/binaries/latest/moonbit-darwin-aarch64.sha256 # SHA checksums for binaries
curl -O -L https://cli.moonbitlang.cn/binaries/latest/moonbit-darwin-aarch64.tar.gz.sha256 # SHA checksums for archive files

为了验证下载的二进制文件和校验和匹配,你可以使用类似sha256sum这样的软件。例如:

curl https://cli.moonbitlang.cn/binaries/latest/moonbit-darwin-aarch64.sha256 | sha256sum -c -