Retrieving List of Node.js Versions

Use the versions operation to retrieve the list of Node.js versions available on the server.

In this chapter:

Request Packet Structure

Response Packet Structure

Samples

 
Request Packet Structure

The request XML packet retrieving the list of Node.js versions available on the server includes the versions operation node:

<packet>
  <extension>
    <call>
      <nodejs>
        <versions/>
      </nodejs>
    </call>
  </extension>
</packet>
 
Response Packet Structure

The output XML packet is structured as follows:

<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.8.0">
  <extension>
    <call>
      <result>
        <status>ok</status>
        <nodejs>
          <versions>
            <version>
              <enabled>...</enabled>
              <version>...</version>
              <path>...</path>
            </version>
            ...
            <version>
              <enabled>...</enabled>
              <version>...</version>
              <path>...</path>
            </version>
         <versions>
        </nodejs>
      </result>
    </call>
  </extension>
</packet>

The result node is required. It wraps the response received from the server. This node contains the following nodes:

  • The status node is required. It specifies the execution status of the enable operation. Data type: result_status. Allowed values: ok | error.
  • The errcode node is optional. It is used to return the error code when the enable operation fails. Data type: unsignedInt.
  • The errtext node is optional. It is used to return the error message if the enable operation fails. Data type: string.
  • The nodejs node is optional. It is present if the operation was completed successfully and contains the following nodes:
    • The versions node contains one or more version nodes containing information about a particular Node.js version. Each version node contains the following nodes:
      • The enabled node is required. It specifies if the version is enabled. Data type: boolean.
      • The version node is required. It specifies the version number. Data type: string.
      • The path node is required. It specifies the path to the Node.js version. Data type: string.
 
Samples

This package retrieves information about the Node.js versions available on the server:

<packet>
  <extension>
    <call>
      <nodejs>
        <versions/>
      </nodejs>
    </call>
  </extension>
</packet>

Response:

<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.8.0">
  <extension>
    <call>
      <result>
        <status>ok</status>
        <nodejs>
          <versions>
            <version>
              <enabled>true</enabled>
              <version>6.3.1</version>
              <path>/opt/plesk/node/6/bin/node</path>
            </version>
            <version>
              <enabled>true</enabled>
              <version>4.4.7</version>
              <path>/opt/plesk/node/4/bin/node</path>
            </version>
          </versions>
        </nodejs>
      </result>
    </call>
  </extension>
</packet>