安裝ROS CDK
本文從Linux、Windows和macOS平臺為您介紹如何安裝阿里云ROS CDK。
前提條件
請確保Node.js和TypeScript滿足以下版本要求:
Node.js:14.17.0及以上。
TypeScript:3.8及以上。
在Linux平臺安裝ROS CDK
以下示例將在CentOS 8.2 64位的系統(tǒng)上安裝ROS CDK。
執(zhí)行以下命令,安裝Node.js、npm、tsc、lerna。
# 由于ROS CDK使用TypeScript開發(fā),因此需要安裝相關(guān)軟件包。 sudo yum install -y nodejs npm sudo npm install typescript -g sudo npm install lerna -g
說明使用以上命令安裝的Node.js版本不符合要求時,您可以進(jìn)入Node.js官網(wǎng)下載對應(yīng)版本進(jìn)行安裝。
執(zhí)行以下命令,安裝CLI。
sudo npm install @alicloud/ros-cdk-cli -g
執(zhí)行以下命令,查看ROS CDK功能列表。
sudo ros-cdk
執(zhí)行命令后,輸出以下內(nèi)容:
Usage: ros-cdk COMMAND Commands: ros-cdk init [TEMPLATE] Create a new, empty CDK project from a template. Invoked without TEMPLATE, the app template will be used. ros-cdk list [STACKS..] Lists all stacks in the app [aliases: ls] ros-cdk synthesize [STACKS..] Synthesizes and prints the ROS template for this stack [aliases: synth] ros-cdk deploy [STACKS..] Deploys the stack(s) named STACKS to ROS into your alicloud account ros-cdk diff [STACKS..] Compares the specified stack with the deployed stack or a local template file, and returns with status 1 if any difference is found ros-cdk destroy [STACKS..] Destroy the stack(s) named STACKS ros-cdk event [STACK..] Get resource events within the resource STACK ros-cdk resource [STACKS..] Get resources in the resource STACKS ros-cdk list-stacks [STACKS..] Get resources in the resource STACKS ros-cdk load-config Load Aliyun CLI config to CDK. ros-cdk config Set your alicloud account configuration. Options: --json, -j Use JSON output instead of YAML when templates are printed to STDOUT [boolean] [default: false] --ignore-errors Ignores synthesis errors, which will likely produce an invalid output [boolean] [default: false] --trace Print trace for stack warnings [boolean] --strict Do not construct stacks with warnings [boolean] --version Show version number [boolean] -h, --help Show help [boolean] If your app has a single stack, there is no need to specify the stack name If one of cdk.json or ~/.cdk.json exists, options specified there will be used as defaults. Settings in cdk.json take precedence.
在Windows平臺安裝ROS CDK
以下示例將在Windows2016 64位的系統(tǒng)上安裝ROS CDK。
安裝Node.js。
訪問Node.js官網(wǎng),下載Node.js安裝包。
據(jù)界面提示,安裝Node.js。
在cmd命令提示符窗口中執(zhí)行以下命令,驗(yàn)證Node.js版本。
node --version v14.17.0
執(zhí)行以下命令,安裝tsc、lerna。
# 由于ROS CDK使用TypeScript開發(fā),因此需要安裝相關(guān)軟件包。 npm install typescript -g npm install lerna -g
執(zhí)行以下命令,安裝CLI。
npm install @alicloud/ros-cdk-cli -g
執(zhí)行以下命令,查看ROS CDK功能列表。
ros-cdk
執(zhí)行命令后,輸出以下內(nèi)容:
Usage: ros-cdk COMMAND Commands: ros-cdk init [TEMPLATE] Create a new, empty CDK project from a template. Invoked without TEMPLATE, the app template will be used. ros-cdk list [STACKS..] Lists all stacks in the app [aliases: ls] ros-cdk synthesize [STACKS..] Synthesizes and prints the ROS template for this stack [aliases: synth] ros-cdk deploy [STACKS..] Deploys the stack(s) named STACKS to ROS into your alicloud account ros-cdk diff [STACKS..] Compares the specified stack with the deployed stack or a local template file, and returns with status 1 if any difference is found ros-cdk destroy [STACKS..] Destroy the stack(s) named STACKS ros-cdk event [STACK..] Get resource events within the resource STACK ros-cdk resource [STACKS..] Get resources in the resource STACKS ros-cdk list-stacks [STACKS..] Get resources in the resource STACKS ros-cdk load-config Load Aliyun CLI config to CDK. ros-cdk config Set your alicloud account configuration. Options: --json, -j Use JSON output instead of YAML when templates are printed to STDOUT [boolean] [default: false] --ignore-errors Ignores synthesis errors, which will likely produce an invalid output [boolean] [default: false] --trace Print trace for stack warnings [boolean] --strict Do not construct stacks with warnings [boolean] --version Show version number [boolean] -h, --help Show help [boolean] If your app has a single stack, there is no need to specify the stack name If one of cdk.json or ~/.cdk.json exists, options specified there will be used as defaults. Settings in cdk.json take precedence.
在macOS平臺安裝ROS CDK
以下示例將在macOS 13.2.1 64位的系統(tǒng)上安裝ROS CDK。
執(zhí)行以下命令,安裝Node.js、npm、tsc、lerna。
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash nvm install 20 npm install -g typescript npm install -g lerna
說明您也可以進(jìn)入Node.js官網(wǎng)下載對應(yīng)版本進(jìn)行安裝。
執(zhí)行以下命令,安裝CLI。
npm install @alicloud/ros-cdk-cli -g
執(zhí)行以下命令,查看ROS CDK功能列表。
ros-cdk
執(zhí)行命令后,輸出以下內(nèi)容:
Usage: ros-cdk COMMAND Commands: ros-cdk init [TEMPLATE] Create a new, empty CDK project from a template. Invoked without TEMPLATE, the app template will be used. ros-cdk list [STACKS..] Lists all stacks in the app [aliases: ls] ros-cdk synthesize [STACKS..] Synthesizes and prints the ROS template for this stack [aliases: synth] ros-cdk deploy [STACKS..] Deploys the stack(s) named STACKS to ROS into your alicloud account ros-cdk diff [STACKS..] Compares the specified stack with the deployed stack or a local template file, and returns with status 1 if any difference is found ros-cdk destroy [STACKS..] Destroy the stack(s) named STACKS ros-cdk event [STACK..] Get resource events within the resource STACK ros-cdk resource [STACKS..] Get resources in the resource STACKS ros-cdk list-stacks [STACKS..] Get resources in the resource STACKS ros-cdk load-config Load Aliyun CLI config to CDK. ros-cdk config Set your alicloud account configuration. Options: --json, -j Use JSON output instead of YAML when templates are printed to STDOUT [boolean] [default: false] --ignore-errors Ignores synthesis errors, which will likely produce an invalid output [boolean] [default: false] --trace Print trace for stack warnings [boolean] --strict Do not construct stacks with warnings [boolean] --version Show version number [boolean] -h, --help Show help [boolean] If your app has a single stack, there is no need to specify the stack name If one of cdk.json or ~/.cdk.json exists, options specified there will be used as defaults. Settings in cdk.json take precedence.