| 📦 Turbo JS 91999d1 k33g 12h ago | 1 | # How to install Node.js |
| 2 | |
| 3 | This guide shows how to get `node` and `npm` onto a machine, install the language server beside them, and check that Turbo JS finds it. It assumes you already have Turbo JS, or are about to — see [how to install the editor](install.md) for that. |
| 4 | |
| 5 | **The editor works without any of this.** Editing, colouring, themes, snippets and terminal windows all run with no Node at all. What needs it is every command in the JavaScript menu, and — through the language server — completion, the Code menu and the error marks in the gutter. |
| 6 | |
| 7 | ## Which pieces you need |
| 8 | |
| 9 | | Piece | What it is for | Comes from | |
| 10 | | --- | --- | --- | |
| 11 | | `node` | The runtime: runs scripts, and is also the test runner (`node --test`) and a syntax checker (`node --check`) | the Node.js installer or a version manager | |
| 12 | | `npm` | The package manager: installs a project's dependencies and, with `-g`, tools such as the language server | ships with Node | |
| 13 | | `npx` | Runs a tool from the project's dependencies, or downloads it into a cache first — how the starter file runs Prettier and ESLint | ships with npm | |
| 14 | | `typescript-language-server` + `typescript@6` | The language server, and the engine it wraps | `npm install -g` | |
| 15 | |
| 16 | Turbo JS was written against Node **24** and npm **11**; any current release works. |
| 17 | |
| 18 | ## Install Node |
| 19 | |
| 20 | Pick one. A version manager is the usual choice on a machine where more than one project lives, because projects pin different Node versions. |
| 21 | |
| 22 | **With nvm** (macOS and Linux): |
| 23 | |
| 24 | ```bash |
| 25 | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash |
| 26 | exec $SHELL |
| 27 | nvm install --lts |
| 28 | ``` |
| 29 | |
| 30 | **With Volta:** |
| 31 | |
| 32 | ```bash |
| 33 | curl https://get.volta.sh | bash |
| 34 | exec $SHELL |
| 35 | volta install node |
| 36 | ``` |
| 37 | |
| 38 | **With Homebrew** (macOS): |
| 39 | |
| 40 | ```bash |
| 41 | brew install node |
| 42 | ``` |
| 43 | |
| 44 | **With the installer** from [nodejs.org](https://nodejs.org), which puts `node` and `npm` in `/usr/local/bin` on macOS and Linux. |
| 45 | |
| 46 | Check: |
| 47 | |
| 48 | ```bash |
| 49 | node --version |
| 50 | npm --version |
| 51 | ``` |
| 52 | |
| 53 | ``` |
| 54 | v24.19.0 |
| 55 | 11.17.0 |
| 56 | ``` |
| 57 | |
| 58 | ## Install the language server |
| 59 | |
| 60 | ```bash |
| 61 | npm install -g typescript-language-server typescript@6 |
| 62 | ``` |
| 63 | |
| 64 | Two packages. The `@6` is not optional: TypeScript 7 is the native port and ships no `tsserver.js`, and the server refuses to start beside it. [How to enable completion](enable-completion.md) says more. |
| 65 | |
| 66 | Turbo JS's own installer will do this when asked: |
| 67 | |
| 68 | ```bash |
| 69 | scripts/install.sh --with-server |
| 70 | ``` |
| 71 | |
| 72 | It runs the same `npm install -g` when no working server is found, and needs `npm` on `PATH`. |
| 73 | |
| 74 | ## Check it |
| 75 | |
| 76 | ```bash |
| 77 | typescript-language-server --version |
| 78 | ``` |
| 79 | |
| 80 | ``` |
| 81 | 6.0.0 |
| 82 | ``` |
| 83 | |
| 84 | And that it really starts — a server whose TypeScript is the wrong version fails only at this point, not at `--version`: |
| 85 | |
| 86 | ```bash |
| 87 | echo | typescript-language-server --stdio |
| 88 | ``` |
| 89 | |
| 90 | It reads an empty line, finds no message in it, and exits quietly. A server that prints *Could not find a valid TypeScript installation* has TypeScript 7 beside it: `npm install -g typescript@6`. |
| 91 | |
| 92 | ## Check that the editor finds it |
| 93 | |
| 94 | Open any `.js` file inside a project and read the right-hand end of the status bar: |
| 95 | |
| 96 | ``` |
| 97 | F1 Describe F2 Save F3 Open F6 Window F10 Menu 1:1 LSP: ready |
| 98 | ``` |
| 99 | |
| 100 | `LSP: ready` means the server started. `LSP: no typescript-language-server — npm install -g typescript-language-server typescript@6` means it was not found, and the message says how to get it. |
| 101 | |
| 102 | **Turbo JS looks in these places, in order**: your `PATH`; `$NVM_BIN`, the directory of the Node version nvm has selected; `$NPM_CONFIG_PREFIX/bin`, or `~/.npm-global/bin` when that variable is unset; `$PNPM_HOME`; `$VOLTA_HOME/bin`, or `~/.volta/bin`; then `/usr/local/bin` and `/opt/homebrew/bin`. The version-manager directories are searched even when they are not on `PATH` — an editor started from a desktop launcher, say — so that the case that otherwise looks like the server being broken works. |
| 103 | |
| 104 | ## Variants |
| 105 | |
| 106 | - **`npm install -g` asks for sudo.** Node from the system installer owns `/usr/local/lib`. Either use `sudo`, or give npm a prefix of your own: `npm config set prefix ~/.npm-global` and add `~/.npm-global/bin` to `PATH` — the editor searches that directory by name. |
| 107 | - **You use pnpm.** `pnpm add -g typescript-language-server typescript@6` puts the server in `$PNPM_HOME`, which the editor searches. |
| 108 | - **You already have `typescript-language-server` but no completion.** Run `echo | typescript-language-server --stdio` and read what it says. Then read the status bar — `Run ▸ Language server status` shows the path the editor found and whether the server answered its handshake. |
| 109 | - **You want to upgrade.** `npm update -g typescript-language-server`. Keep `typescript` on 6 until the server can start with 7. Restart the editor: it starts one server per session and does not notice a new binary until then. |
| 110 | - **You are installing for CI, or into an image.** `node:24-alpine` and the other official images carry `node`, `npm` and `npx`; `npm install -g typescript-language-server typescript@6` in a `RUN` line adds the server. The editor cannot use a server inside a container, so this is for running the project's commands, not for completion. |
| 111 | - **You want to be sure the editor is not simply finding it on `PATH`.** Start it with a stripped environment — `env PATH=/usr/bin:/bin turbo-js main.js` — and the status bar should still say `LSP: ready` from one of the directories above. |
| 112 | |
| 113 | ## What each piece is for, from the editor's side |
| 114 | |
| 115 | | Piece | What the editor uses it for | |
| 116 | | --- | --- | |
| 117 | | `typescript-language-server` | Completion, hover, definitions, references, implementations, the file's and the project's symbols, and the error marks | |
| 118 | | `node` | The **Run** and **Test** items of the JavaScript menu | |
| 119 | | `npm` | The **Install** and **Start** items | |
| 120 | | `npx` | The **Format** and **Lint** items | |
| 121 | |
| 122 | ## See also |
| 123 | |
| 124 | - [How to enable completion](enable-completion.md) — what to do when the server is installed and still says nothing |
| 125 | - [How to run Node commands from the editor](run-node-commands.md) — the JavaScript menu |
| 126 | - [Colouring and completion](../explanation/colouring-and-completion.md) — why the server is TypeScript's |