全部產品
Search
文件中心

Resource Orchestration Service:安裝ROS CDK

更新時間:Sep 24, 2024

本文從Linux、Windows和macOS平台為您介紹如何安裝阿里雲ROS CDK。

前提條件

請確保Node.js和TypeScript滿足以下版本要求:

  • Node.js:14.17.0及以上。

  • TypeScript:3.8及以上。

在Linux平台安裝ROS CDK

以下樣本將在CentOS 8.2 64位的系統上安裝ROS CDK。

  1. 執行以下命令,安裝Node.js、npm、tsc、lerna。

    # 由於ROS CDK使用TypeScript開發,因此需要安裝相關軟體包。
    sudo yum install -y nodejs npm
    sudo npm install typescript -g
    sudo npm install lerna -g
    說明

    使用以上命令安裝的Node.js版本不符合要求時,您可以進入Node.js官網下載對應版本進行安裝。

  2. 執行以下命令,安裝CLI。

    sudo npm install @alicloud/ros-cdk-cli -g
  3. 執行以下命令,查看ROS CDK功能列表。

    sudo ros-cdk

    執行命令後,輸出以下內容:

    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位的系統上安裝ROS CDK。

  1. 安裝Node.js。

    1. 訪問Node.js官網,下載Node.js安裝包。

    2. 據介面提示,安裝Node.js。

    3. 在cmd命令提示字元視窗中執行以下命令,驗證Node.js版本。

      node --version
      v14.17.0
  2. 執行以下命令,安裝tsc、lerna。

    # 由於ROS CDK使用TypeScript開發,因此需要安裝相關軟體包。
    npm install typescript -g
    npm install lerna -g
  3. 執行以下命令,安裝CLI。

    npm install @alicloud/ros-cdk-cli -g
  4. 執行以下命令,查看ROS CDK功能列表。

    ros-cdk

    執行命令後,輸出以下內容:

    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位的系統上安裝ROS CDK。

  1. 執行以下命令,安裝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
    說明

    您也可以進入Node.js官網下載對應版本進行安裝。

  2. 執行以下命令,安裝CLI。

    npm install @alicloud/ros-cdk-cli -g
  3. 執行以下命令,查看ROS CDK功能列表。

    ros-cdk

    執行命令後,輸出以下內容:

    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.