EN Doc Β Β Β δΈζζζ‘£
JavaScript / TypeScript support for the Godot engine. Gode is powered by V8 and Node.js, and runs on all native platforms.
| Platform | Windows | Android | macOS | iOS | Linux |
|---|---|---|---|---|---|
| Supported | β | β | β | β | β |
| MinVersion | 10 | 9 | 10.15 | 16 | Ubuntu 22 |
- Download the latest Gode plugin.
- Extract the
godedirectory from the archive into your project'saddonsdirectory. Create the directory first if it does not exist.
The installed directory structure should look like this:
my_project
βββ addons
β βββ gode
β βββ binary
β βββ gode.gd
β βββ gode.gd.uid
β βββ plugin.cfg
β βββ runtime
β βββ types- Open Godot and go to
Project > Project Settings > Plugins. - Find
godeand enable it.
After enabling the plugin, you can choose JavaScript or TypeScript when creating a script.
Create res://scripts/hello.js:
import { Node } from "godot";
export default class Hello extends Node {
_ready() {
console.log("Hello from Gode");
}
}Attach this script to any node in the Godot editor and run the scene.
JavaScript scripts can import Godot types with syntax like import { Node } from "godot". They can also import other .js files in your project with relative paths:
import { PlayerState } from "./player_state.js";If you only write plain JavaScript scripts, no extra setup is required. To use npm packages, initialize npm in the project root:
npm init -yInstall a dependency:
npm install lodashUse it in a script:
import { Node } from "godot";
import lodash from "lodash";
export default class Demo extends Node {
_ready() {
console.log(lodash.camelCase("hello gode"));
}
}Gode resolves npm packages from res://node_modules. When exporting your project, make sure the required node_modules, package.json, and script files are included in the exported resources.
TypeScript scripts are compiled to matching JavaScript files under res://dist. It is recommended to create tsconfig.json in the project root:
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"baseUrl": ".",
"paths": {
"godot": ["addons/gode/types/godot.d.ts"]
},
"types": ["node"]
},
"include": ["scripts/**/*.ts", "addons/gode/types/**/*.d.ts"],
"exclude": ["dist", "node_modules"]
}Install TypeScript and Node types:
npm install -D typescript @types/nodeCreate res://scripts/hello.ts:
import { Node } from "godot";
export default class Hello extends Node {
_ready(): void {
console.log("Hello from TypeScript");
}
}After enabling the plugin, if tsconfig.json exists in the project root, Gode will try to start TypeScript watch compilation. You can also run it manually:
npx tsc --watchThe example directory in this repository is a complete Godot project with JavaScript scripts, the plugin directory, and package.json. Open it directly with Godot:
godot --path exampleExample scripts:
example/scripts/main_menu.jsexample/scripts/test_workspace.jsexample/scripts/test_catalog.js
JavaScript / TypeScript script types do not appear after enabling the plugin
Make sure the plugin directory is res://addons/gode and that res://addons/gode/plugin.cfg exists. Then enable the plugin again or restart Godot.
TypeScript does not compile automatically
Make sure tsconfig.json exists in the project root and typescript is installed. You can also run npx tsc --watch manually to debug the configuration.
npm packages cannot be found at runtime
Make sure dependencies are installed in the Godot project root under node_modules. When exporting the project, include the required packages and package.json.
The plugin fails to load after export
Make sure the export platform is listed as supported, and that the matching binary exists in addons/gode/binary/gode.gdextension.