Build Development Environment

Last Updated on : 2024-06-05 03:14:28download

This topic describes how to build the environments required by panel development.

Install development tools

Before you develop an SDK-based panel, download and install the following recommended editors as needed:

  • Visual Studio Code (recommended): supports common built-in features, such as formatting and navigation. This editor is subject to a high level of community engagement.
  • WebStorm: a high-performance integrated development environment (IDE).
  • Sublime Text: a lightweight editor.
  • Atom: a lightweight editor.

Install NVM

  • If this is your first installation, set up the environment variable as per the instructions.
  • If you have any questions during the installation process, refer to NVM official documentation.
  1. Open the Terminal.

  2. Install the NVM.

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
    
  3. (Optional) Enter nvm -v to confirm that the NVM is installed as expected.

    If a version number is returned, the installation is successful. If the error is returned: nvm: command not found, follow the instructions in FAQs to fix the error.

  4. Enter nvm install 14.21.3 to install Node.js v14.21.3.

    The RN version is 0.59.10, so we recommend installing Node.js 14 or Node.js 12. Specifically, Node.js 12 is recommended for Windows and Node.js 14 for Mac.

  5. (Optional) Run the command nvm use to switch among Node.js versions.

    nvm use 14.21.3   
    

Install Yarn

  1. Open the Terminal.

  2. Enter npm install -g yarn to install Yarn.

  3. (Optional) Enter yarn -v to confirm that Yarn is installed as expected.

Install Homebrew and Watchman

This section applies to macOS only.

  1. Refer to the official documentation of Homebrew.
  2. Open the Terminal.
  3. Enter brew install watchman to install watchman.

Install tuya-panel-cli

Make sure the development environment is built. Check the version number of each program to determine whether the installation is successful.

  • nvm -v
  • yarn -v
  • watchman -v

The command-line interface (CLI) tuya-panel-cli is required during cloud development. To install it, run the following command:

  • MacOS & Linux

    curl -fsSL https://cdn.jsdelivr.net/gh/tuya/tuya-panel-cli/install.sh | sh
    

    If this is your first installation, set up the environment variable as per the instruction.

  • Windows PowerShell

    iwr https://cdn.jsdelivr.net/gh/tuya/tuya-panel-cli/install.ps1 -useb | iex
    

    The iwr command cannot run on early versions of PowerShell. To resolve this problem, see iwr cannot be recognized on Windows.

Run tuya-panel-cli help to see if all available commands are printed to determine whether the installation is successful.

The installation script might fail to be obtained due to network problems. In this case, follow the instructions in Manual installation or Mac/Linux manual installation to fix the problem.

FAQs

Q: After nvm -v is entered, why has the error been returned: nvm: command not found?

A: The possible reason is that the path where NVM is located is not specified as an environment variable. You can perform the following steps and set the environment variable:

  1. Open the Terminal.

  2. Enter cd ~ to go to the Home directory of the current account.

  3. Run the following command to open the configuration file.

    • Windows

      open .bash_profile
      
    • Latest version of macOS

      open .zshrc
      
  4. Copy and paste the following code block to the configuration file and save the file.

    export NVM_DIR="$HOME/.nvm"
     [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
    
  5. Enter source .bash_profile or source .zshrc to reload the configuration file.

  6. Enter nvm -v to view the NVM version and check whether the installation is successful.

Q: Homebrew could not be installed on macOS. How can I fix the problem?

A: If you have not installed Xcode command-line tools on your computer, the installation of Homebrew might fail.

  • Method 1: Install Xcode.

  • Method 2: Run the online installation command to install Homebrew.

    1. Open the macOS Terminal.
    2. Enter cd ~ to go to the Home directory of the current account.
    3. Enter xcode-select --install to install Xcode command-line tools.

References

During the installation or running of React Native (RN), if an error message appears, you can check the troubleshooting document from the RN community.