Ionic CLI
Ionic 命令行接口 (CLI) 是开发 Ionic 应用的首选工具。
¥The Ionic command-line interface (CLI) is the go-to tool for developing Ionic apps.
安装
¥Installation
Ionic CLI 可以使用 npm 进行全局安装:
¥The Ionic CLI can be installed globally with npm:
npm install -g @ionic/cli
帮助
¥Help
Ionic CLI 附带了可通过 --help
标志访问的命令文档。
¥The Ionic CLI ships with command documentation that is accessible with the --help
flag.
$ ionic --help
$ ionic <command> --help
$ ionic <command> <subcommand> --help
确保在你的项目目录中运行 ionic <command> --help
。
¥Be sure to run ionic <command> --help
in your project directory.
对于某些命令,例如 ionic serve
,帮助文档与你的项目类型相关,例如 React 与 Angular。
¥For some commands, such as ionic serve
, the help documentation is contextual to the type of your project, e.g. React vs Angular.
架构
¥Architecture
Ionic CLI 是使用 TypeScript 和 Node.js 构建的。它支持 Node 10.3+,但始终建议使用最新的 Node LTS。关注开源 GitHub 存储库 上的开发。
¥The Ionic CLI is built with TypeScript and Node.js. It supports Node 10.3+, but the latest Node LTS is always recommended. Follow development on the open source GitHub repository.
故障排除
¥Troubleshooting
要解决 Ionic CLI 的问题,以下内容可能有用:
¥To troubleshoot issues with the Ionic CLI, the following may be useful:
-
确保安装了最新版本的 Ionic CLI。通过运行
ionic --version
获取已安装的版本。¥Make sure the latest version of the Ionic CLI is installed. Get the installed version by running
ionic --version
. -
确保安装了最新的 Node LTS。请参阅 Node 与 npm 环境设置。
¥Make sure the latest Node LTS is installed. See Node & npm environment setup.
-
--verbose
标志打印调试消息,这可能会缩小问题范围。¥The
--verbose
flag prints debugging messages, which may narrow down the issue. -
连接问题可能是由于代理设置配置不当造成的。请参阅 使用代理 配置请求代理。
¥Connection issues may be due to improperly configured proxy settings. See Using a Proxy to configure request proxying.
-
所有平台上的全局 Ionic CLI 配置目录都是
~/.ionic
。它可以安全地删除,Ionic CLI 将重新填充它,但所有配置(包括用户会话)都将丢失。将此目录配置为 CLI 环境变量。¥The global Ionic CLI configuration directory is
~/.ionic
on all platforms. It can safely be deleted and the Ionic CLI will repopulate it, but all configuration (including user sessions) will be lost. Configure this directory with CLI environment variables.