Skip to content

安装

¥Install

你需要安装 Meteor 命令行工具来创建、运行和管理你的 Meteor.js 项目。检查先决条件并按照下面的安装过程进行操作。

¥You need to install the Meteor command line tool to create, run, and manage your Meteor.js projects. Check the prerequisites and follow the installation process below.

bash
npx meteor

先决条件

¥Prerequisites

操作系统 (OS)

¥Operating System (OS)

  • Meteor 目前支持 OS X、Windows 和 Linux。仅支持 64 位。

    ¥Meteor currently supports OS X, Windows, and Linux. Only 64-bit is supported.

  • Meteor 支持 Windows 7/Windows Server 2008 R2 及更高版本。

    ¥Meteor supports Windows 7 / Windows Server 2008 R2 and up.

  • 从 Meteor 2.5.1 开始,Apple M1 均受原生支持(对于旧版本,需要 rosetta 终端)。

    ¥Apple M1 is natively supported from Meteor 2.5.1 onward (for older versions, rosetta terminal is required).

  • 如果你使用的是 Mac M1(Arm64 版本),则需要安装 Rosetta 2,因为 Meteor 使用它来运行 MongoDB。检查如何安装 此处

    ¥If you are on a Mac M1 (Arm64 version) you need to have Rosetta 2 installed, as Meteor uses it for running MongoDB. Check how to install it here.

  • 禁用防病毒软件(Windows Defender 等)将提高性能。

    ¥Disabling antivirus (Windows Defender, etc.) will improve performance.

  • 为了兼容,Linux 二进制文件使用 CentOS 6.4 i386/amd64 构建。

    ¥For compatibility, Linux binaries are built with CentOS 6.4 i386/amd64.

移动开发

¥Mobile Development

  • iOS 开发需要最新的 Xcode。

    ¥iOS development requires the latest Xcode.

安装

¥Installation

通过运行以下命令之一从你的终端安装最新的官方版本的 Meteor.js。你可以查看我们的 changelog 以了解发行说明。

¥Install the latest official version of Meteor.js from your terminal by running one of the commands below. You can check our changelog for the release notes.

对于 Windows、Linux 和 OS X,你可以运行以下命令:

¥For Windows, Linux and OS X, you can run the following command:

bash
npx meteor

提示

如果你在安装 npx 时遇到错误,则可以尝试运行 npx clear-npx-cache

¥If you get an error with the installation npx you can try running npx clear-npx-cache

rm -rf ~/.npm/_npx

¥or rm -rf ~/.npm/_npx

如果错误仍然存​​在,请尝试使用 npm 安装 Meteor:

¥if the error persists, please try to install Meteor using npm:

bash
npm install -g meteor --foreground-script

确保你已安装 Node.js v20 或更高版本。

¥Make sure you have Node.js v20 or higher installed.

Linux 和 OS X 的另一种方法是使用 curl 安装 Meteor:

¥An alternative for Linux and OS X, is to install Meteor by using curl:

bash
curl https://install.meteor.com/ | sh

你还可以使用 curl 安装特定的 Meteor.js 版本:

¥You can also install a specific Meteor.js version by using curl:

bash
curl https://install.meteor.com/\?release\=2.8 | sh

请勿在项目的 package.json 中安装 npm Meteor 工具。此库只是一个安装程序。

¥Do not install the npm Meteor Tool in your project's package.json. This library is just an installer.

故障排除

¥Troubleshooting

如果你的用户没有安装全局二进制文件的权限,而你需要使用 sudo,则需要在上述命令后附加 --unsafe-perm:

¥If your user doesn't have permission to install global binaries, and you need to use sudo, it's necessary to append --unsafe-perm to the above command:

bash
sudo npm install -g meteor --unsafe-perm

我们强烈反对使用具有 root 权限的 Node.js 或 Meteor。仅当你知道自己在做什么时才使用 sudo 运行上述命令。

¥We strongly discourage the usage of Node.js or Meteor with root permissions. Only run the above command with sudo if you know what you are doing.

如果你仅因为分发默认权限系统 检查此链接以修复它 而使用 sudo。

¥If you only use sudo because of a distribution default permission system, check this link for fixing it.

在某些情况下,你可能会收到此错误 npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules,因为你的 Node.js 安装是在错误的权限下执行的。解决此问题的简单方法是使用 nvm 安装 Node.js 并强制在终端中使用它。你可以通过运行 nvm use 14 在终端的当前会话中强制执行它。

¥In some cases you can get this error npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules because your Node.js installation was performed with wrong permissions. An easy way to fix this is to install Node.js using nvm and forcing it to be used in your terminal. You can force it in the current session of your terminal by running nvm use 14.

PATH 管理

¥PATH management

默认情况下,Meteor 安装程序会通过根据需要更新你的 .bashrc.bash_profile.zshrc 将其安装路径(默认情况下为 ~/.meteor/)添加到你的 PATH。要禁用此行为,请通过运行安装 Meteor:

¥By default, the Meteor installer adds its install path (by default, ~/.meteor/) to your PATH by updating either your .bashrc, .bash_profile, or .zshrc as appropriate. To disable this behavior, install Meteor by running:

bash
npm install -g meteor --ignore-meteor-setup-exec-path --foreground-script

(或通过设置环境变量 npm_config_ignore_meteor_setup_exec_path=true

¥(or by setting the environment variable npm_config_ignore_meteor_setup_exec_path=true)

Apple M1 上的旧版本

¥Old Versions on Apple M1

对于 Apple M1 计算机,如果你需要运行旧版本的 Meteor(2.5.1 之前),你可以按如下方式添加 Rosetta 前缀:

¥For Apple M1 computers, you can append Rosetta prefix as following, if you need to run older versions of Meteor (before 2.5.1):

bash
arch -x86_64 npm install -g meteor

或者在“应用”文件夹中选择“终端”,按 CMD(⌘)+I 并选中 "使用 Rosetta 打开" 选项。

¥or select Terminal in the Applications folder, press CMD(⌘)+I and check the "Open using Rosetta" option.

Meteor Docker 镜像

¥Meteor Docker image

你还可以使用 Docker 容器在 CI 中甚至在本地开发工具链中运行 Meteor。

¥You can also use a Docker container for running Meteor inside your CI, or even in your local development toolchain.

我们确实提供了基于 Meteor/Meteor-base ubuntu 的 Docker 映像,该映像预先打包了 Node.JS 和 Meteor,并以本地用户(而不是 root)身份运行。

¥We do provide the meteor/meteor-base ubuntu-based Docker image, that comes pre-bundled with Node.JS and Meteor, and runs it as a local user (not as root).

你可以参考我们的 Meteor/Galaxy-Images 存储库以了解如何使用它以及最新版本。有关 Meteor-base 的更多信息,请点击此处。

¥You can refer to our meteor/galaxy-images repository to see how to use it, and the latest version. More about meteor-base here.

Windows 用户注意事项

¥Note for Windows users

在 Windows 上,启用 Windows 开发者模式 时安装程序运行速度更快。安装会提取大量小文件,Windows Defender 可能会导致这些文件非常慢。

¥On Windows, the installer runs faster when Windows Developer Mode is enabled. The installation extracts a large number of small files, which Windows Defender can cause to be very slow.

Node 版本管理器

¥Node version manager

如果你使用的 Node 版本管理器为每个 Node 版本使用单独的全局 node_modules 文件夹,则在第一次更改为 Node 版本时需要重新安装 meteor npm 包。否则,将不再找到 meteor 命令。

¥If you use a node version manager that uses a separate global node_modules folder for each Node version, you will need to re-install the meteor npm package when changing to a Node version for the first time. Otherwise, the meteor command will no longer be found.

fish shell 用户注意事项 (Linux)

¥Note for fish shell users (Linux)

为了能够从 fish 使用 meteor 命令,需要在 $PATH 中包含 /home/<user>/.meteor;为此,只需在 /home/<user>/.config/fish/config.fish 文件中添加此行(将 <user> 替换为你的用户名):

¥To be able to user meteor command from fish it's needed to include /home/<user>/.meteor in $PATH; to do that just add this line in /home/<user>/.config/fish/config.fish file (replace <user> with your username):

set PATH /home/<user>/.meteor $PATH

卸载 Meteor

¥Uninstalling Meteor

如果你使用 npx 安装了 Meteor,则可以通过运行以下命令将其删除:

¥If you installed Meteor using npx, you can remove it by running:

bash
npx meteor uninstall

如果你使用 curl 或作为后备解决方案安装了 Meteor,请运行:

¥If you installed Meteor using curl or as a fallback solution, run:

rm -rf ~/.meteor sudo rm /usr/local/bin/meteor