# Using external Node libraries

External libraries enhance the functionality of your UI Bakery app by allowing you to use a*dditional JavaScript code*. You can take advantage of a vast number of JavaScript libraries to bring date manipulation, data parsing, and much more into your automations.

## Finding libraries

1. Go to the [npm website](https://www.npmjs.com/) and search for a package, for example *XML parsing*, to find the libraries you need.
2. Select a library from the search results to view its *Details* page.
3. Click on the **Versions** tab at the top.&#x20;

{% hint style="info" %}
It is recommended to use the **most recent stable version** listed.
{% endhint %}

4. Here, copy the *package name* and *version number* and paste them in the **Packages** tab of the Automations page in the following format:

`"xml2js": "^0.6.2"`

{% hint style="warning" %}
Libraries dependent on the `fs` and `child_process` modules are currently not supported.
{% endhint %}

{% @arcade/embed flowId="GqHQbFl4jSwXPfiNpexU" url="<https://app.arcade.software/share/GqHQbFl4jSwXPfiNpexU>" %}

## Using libraries in your code

After adding the package number and version, you simply need to use `import` statements to include the library in your Automations. Below is an example of an *xml2js* library added to the Automation action:

```javascript
import { parseString } from 'xml2js';

// Or use result of other steps, for example, HTTP request as const xml = {{data}}
const xml = `<note>
  <to>User</to>
  <from>Library</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>`;

return new Promise((resolve, reject) => {
  parseString(xml, (err, result) => {
    if (err) {
      reject(err);
    } else {
      resolve(result);
    }
  });
});
```

{% @arcade/embed flowId="eREtTejTKkUHr9omZG7x" url="<https://app.arcade.software/share/eREtTejTKkUHr9omZG7x>" %}

### `require()` imports

`require()` imports are not supported in the Automations runtime. You should use the ES6 module import syntax instead. \
For modules using CommonJS *require*, replace it with an ES6 `import` statement.

**Before:**

`const yaml = require('js-yaml');`

**After:**

`import yaml from 'js-yaml';`
