1.9 KiB

display_name description icon maintainer_github verified tags
Node.js Install Node.js via nvm ../../../../.icons/node.svg TheZoker false
helper
nodejs

nodejs

Automatically installs Node.js via nvm. It can also install multiple versions of node and set a default version. If no options are specified, the latest version is installed.

module "nodejs" {
  count    = data.coder_workspace.me.start_count
  source   = "registry.coder.com/thezoker/nodejs/coder"
  version  = "1.0.14"
  agent_id = coder_agent.example.id
}

Install multiple versions

This installs multiple versions of Node.js:

module "nodejs" {
  count    = data.coder_workspace.me.start_count
  source   = "registry.coder.com/thezoker/nodejs/coder"
  version  = "1.0.14"
  agent_id = coder_agent.example.id
  node_versions = [
    "18",
    "20",
    "node"
  ]
  default_node_version = "20"
}

Pre and Post Install Scripts

Use pre_install_script and post_install_script to run custom scripts before and after Node.js installation.

module "nodejs" {
  count    = data.coder_workspace.me.start_count
  source   = "registry.coder.com/thezoker/nodejs/coder"
  version  = "1.0.14"
  agent_id = coder_agent.example.id

  pre_install_script  = "echo 'Setting up prerequisites...'"
  post_install_script = "npm install -g yarn pnpm"
}

Full example

A example with all available options:

module "nodejs" {
  count              = data.coder_workspace.me.start_count
  source             = "registry.coder.com/thezoker/nodejs/coder"
  version            = "1.0.14"
  agent_id           = coder_agent.example.id
  nvm_version        = "v0.39.7"
  nvm_install_prefix = "/opt/nvm"
  node_versions = [
    "18",
    "20",
    "node"
  ]
  default_node_version = "20"
  pre_install_script   = "echo 'Pre-install setup'"
  post_install_script  = "npm install -g typescript"
}