I an trying to build a React.js application before zipping it with this code:
resource "null_resource" "build" {
triggers = {
always_run = "${timestamp()}"
}
provisioner "local-exec" {
command = "cd ${path.module}/.. && npm run build"
environment = var.environment_variables
}
}
data "archive_file" "source_zip" {
depends_on = [null_resource.build]
type = "zip"
source_dir = "../build"
output_path = "dist/source.zip"
}
This code runs well on my local machine but fails on Terraform cloud (https://www.terraform.io/). NPM seems to be not installed on the machine where terraform runs. Here is the erro I get:
Error: Error running command 'cd ./.. && npm run build': exit status 127. Output: /bin/sh: 1: npm: not found
So, how to have npm installed on the Terraform cloud?