User data not executing node script when droplet is created over the api

March 29, 2019 593 views
API Ubuntu 18.04

I am creating a droplet from a snapshot. The droplet contains a folder called youtube-uploader in the root directory. My cloud config looks like this:

  - touch test.txt
  - node /root/youtuber-uploader/index.js ID-1234
  - touch hello.txt

The droplet is created successfully but the node command is never executed. Both test.txt and hello.txt is created at /. If I ssh into the droplet and run the node command, everything works as expected.

I am making the call to the DO api through a node script and the axios package. The request looks like the following

axios('', {
    method: 'POST', 
    headers: {
       Authorization: 'xxxxxx'
    'Content-Type': 'application/json',
    data: {
      "name": 'testing'
      "region": "nyc3",
      "size": "s-6vcpu-16gb",
      "image": "45281496",
      "ssh_keys": [
      "backups": false,
      "ipv6": false,
      "user_data": `#cloud-config
  - touch test.txt
  - node /root/youtuber-uploader/index.js ${}
  - touch hello.txt`,
      "private_networking": null,
      "volumes": null,
      "tags": [

Is there any obvious mistake here? It might be that the script is being called but the id is not being passed so the script is not doing the work its supposed to. Is there anyway I can check for this?

1 Answer
jarland MOD March 29, 2019
Accepted Answer


Most likely the script is running, but not doing what you expect it to. You may be able to find helpful information in one of these log files:



  • The cloud-init-output.log file says Error: Cannot find module '/root/youtube-uploader/index.js'.

    What could be the reason for this? The file certainly exists.

Have another answer? Share your knowledge.