You'll need Node.js to set up the Zendesk app scaffold. Node.js is JavaScript runtime environment for executing JavaScript code outside the browser. It lets you use JavaScript to build web applications.

This article describes how to install and manage different versions of Node.js on your system with a tool called nodenv (for Node environment). nodenv lets you install versions of Node.js side-by-side and specify which one to use on a per-project basis or globally. This is very useful if you need to work with a particular version of Node.js.

If nodenv looks familiar to you, it's because of its close resemblance to rbenv. It accomplishes the same tasks with the same syntax as rbenv.

Topics covered in this article:

The other articles in the series cover the following topics:

Disclaimer: Zendesk can't provide support for third-party technologies such as Node.js or nodenv. Post any issues in the comments section or search for solutions online.

Installing nodenv in Ubuntu

This section assumes you enabled the Windows Linux Subsystem and installed Ubuntu from the Microsoft Store. For instructions, see Setting up a Bash shell in Windows 10 in the first article of this series.

To install nodenv in Ubuntu in Windows

  1. In PowerShell or at the Windows command prompt, run bash to start the Bash shell.
  2. Run the following housecleaning command in the Bash shell:

    $ sudo apt-get update

    apt-get is the package manager in Ubuntu. See AptGet/Howto on the Ubuntu site.

  3. Install nodenv by cloning it from Github:

    $ git clone https://github.com/nodenv/nodenv.git ~/.nodenv
  4. Add nodenv to your system's $PATH variable and reload the shell:

    $ echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bashrc
    $ echo 'eval "$(nodenv init -)"' >> ~/.bashrc
    $ source ~/.bashrc
  5. Install a nodenv plugin called node-build by cloning it from Github:

    $ git clone https://github.com/nodenv/node-build.git $(nodenv root)/plugins/node-build

    node-build is used to build Node.js versions from source.

  6. Verify that nodenv is configured properly:

    $ type nodenv

    The output should say that nodenv is a function.

You can now install and manage multiple versions of Node.js on your system. See Installing and using different versions of Node.js below.

Installing nodenv in macOS

You can use Homebrew, the package manager you installed in the first article of this series, to install nodenv.

To install nodenv in macOS

  1. In Terminal, enter the following commands, waiting for the first process to finish before entering the next line:

    $ brew update
    $ brew install nodenv
  2. Add nodenv to your system's $PATH variable and reload the shell:

    $ echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bashrc
    $ echo 'eval "$(nodenv init -)"' >> ~/.bashrc
    $ source ~/.bashrc
  3. Verify that nodenv is configured properly:

    $ type nodenv

    The output should say that nodenv is a function.

You can now install and manage multiple versions of Node.js on your system.

Installing and using different versions of Node.js

After installing nodenv, you can use it to install versions of Node.js side-by-side and then switch between versions.

If you don't have Node.js installed on your system, you can use nodenv to install it. To check if Node.js is installed, run the following command:

$ node -v

To install a version of Node.js

  1. List the versions you can install:

    $ nodenv install --list

    You can only install versions on the list.

  2. Install a version:

    $ nodenv install <version>

    where <version> is a string from the list.

    Example:

    $ nodenv install 12.9.1

    Note: It can take a few minutes to build and install a version of Node.js from source. Please be patient.

To use a version for a specific project

  • Run the following command in the project folder:

    $ nodenv local <version>

    where <version> is an installed version.

    Example:

    $ cd ~/projects/my_cool_app$ nodenv local 12.9.1

    Tip: To list the installed versions, run nodenv versions.

To use a version as the default version on your system

  • Run nodenv global <version>.

    where <version> is an installed version.

    Example:

    $ nodenv global 12.9.1

To list the versions installed on your system

$ nodenv versions

To list the working version

$ nodenv version

Installing Node packages

The package manager for Node.js is called npm, which stands for Node Package Manager. It's both a package manager and a package repository.

The package manager is installed when you install Node.js.

Note: If you haven't used Node.js on your system yet, make sure to run nodenv global <version> or nodenv local <version> to activate a version, and then restart your shell.

Use the following command to install a package:

$ npm install <package-name>

See the npm repository for package names.

Note: Depending on your system and the package, it can take a few minutes to install a package. Please be patient.

Include the --global option to make the package available everywhere on your system.

$ npm install --global <package-name>

Example

  1. Install a games package called node-games:

    $ npm install --global node-games
  2. Restart your shell.
  3. Run:

    $ node-games

    The output should look like the following:

    usage: node-games <game>
    Games- spacecraft- snake- tanks
  4. Try one out:

    $ node-games spacecraft

    Press Control+C to exit the game.

Don't get too distracted. Now you can install app development tools and start working with the Zendesk platform.

Next steps