gio dev
Run the GioJS server in development mode: the project is watched, edits restart the Node worker and reload open tabs, and errors show in an overlay.
npx gio devpnpm exec gio devyarn gio devbunx gio devgio dev [--port <port>] [--host <ip>] [--open]Reference
| Option | Type | Default | Description |
|---|---|---|---|
-p, --port <port> | number | 3000 | The port to listen on, 0-65535. Passed to the server as GIO_PORT, which outranks PORT and [server] port; without the flag those decide, then 3000. Anything else is a usage error. |
-H, --host <ip> | string | 0.0.0.0 | The IP address to bind, passed as GIO_HOST (over [server] host). 0.0.0.0 listens on every IPv4 interface, 127.0.0.1 on this machine only. IPv6 works with or without brackets (::, [::], ::1); GIO_HOST always receives it bracketed. localhost is the one name accepted and means 127.0.0.1; other host names are a usage error, because the server binds IP addresses only. |
--open | boolean | false | Open the local URL in the default browser once the app is ready (open on macOS, cmd /c start on Windows, xdg-open elsewhere). If no browser can be started, gio prints the URL instead. |
-h, --help | boolean | - | Print the command's help and exit with 0. |
Behavior
- Finds the server binary (
GIO_SERVER_BIN, else the@gio.js/server-<platform>package). Without one it prints which package to install and exits with1(see When the server binary is missing). - Asks the binary where it will listen (
giojs-server --check-config), so the address comes from the same sources the server uses:GIO_PORT/GIO_HOST(which--port/--hostset), thenPORT- each from the environment or, when the environment does not set it, the.envfiles - thengio.toml's[server]table, then0.0.0.0:3000. - Starts the server with
NODE_ENV=development, whatever the shell had, and withGIO_EXIT_ON_STDIN_EOF=1and a stdin pipe it never writes: if thegioprocess dies, even bySIGKILL, the server sees the pipe close and shuts down instead of holding the port. - Polls
/_gio/healthuntil it reports the Node worker ready (or, with[health] enabled = false, until anything answers), then prints the banner below and opens the browser for--open. - Stays in the foreground until the server exits, and exits with the server's exit code (
1if the server was killed by a signal). Ctrl+C andSIGTERMshut the server down gracefully.
GioJS 0.1.0-beta.8 (dev)
- Local: http://localhost:3000
- Network: http://192.168.1.20:3000Network lists one URL per non-internal IPv4 address when the server listens on every interface. With a loopback host it says not exposed (listening on loopback only; use --host 0.0.0.0). The banner is skipped when the configuration has an error (the server prints it and exits 1) and when the port is 0.
What development mode changes
The mode is the server's, and the Node worker always runs in the same one. In development:
- The
.env.development.local,.env.local,.env.developmentand.envfiles load (see Environment Variables). - Render errors show in the error overlay with a code frame and an open-in-editor link, and
/_gio/devtoolsserves the dev dashboard. Both answer only local hosts unless[dev] allowed_hostslists more (see Dev endpoints);[dev] devtools = falseturns them off. require_sessionguards work withoutGIO_SESSION_SECRET: the server generates an ephemeral secret, so sessions reset when it restarts.- One render worker, whatever
[server] workerssays: every edit restarts it with a fresh build. - The project is watched (next section).
File watching
The whole project is watched, not just app/. A change under app/, in components/, lib/, src/, hooks/, or to gio.toml, gio.config.ts, middleware.ts or tsconfig.json clears the page cache, re-transforms app CSS, restarts the Node worker and reloads open tabs. Edits under public/ refresh which files are served at the site root and reload the browser without a restart.
gio.toml edit restarts the worker like any other, but the new settings do not take effect: the Rust server reads gio.toml once, at startup, and keeps running with what it read. Stop gio dev (Ctrl+C) and run it again. Edits to the .env files are not watched at all (no restart, no reload): restart gio dev to apply them, as for a change to the environment.- A
gio.tomledit restarts the worker, but the new settings do not apply: the Rust server readsgio.tomlonce, at startup. Stop and startgio devafter changing it. The same goes for the.envfiles, which are read once too; editing them restarts nothing. - Any change under
app/restarts the worker. Elsewhere only these extensions do:.ts .tsx .js .jsx .mjs .cjs .mts .cts .json .css .toml, plus directories created, deleted or moved. Databases, logs and uploads the app writes into the project never restart the worker that wrote them. - Never watched:
node_modules/at any depth, hidden directories such as.git/and.gio/(except.well-known/), and the top-levelout/,dist/,build/,target/,standalone/andcoverage/. Editor scratch files (~backups,.swp/.swx,4913,.#locks) are ignored. [dev] watch_ignoreglobs exclude more (data files with a source extension, likedata/*.json), and[dev] watch = falseturns the watcher off.- Ignored directories are kept out of the watch registration, so a large
node_modules/does not use up Linux inotify watches. If a project hits the limit anyway, the server logs which directory went unwatched; raisefs.inotify.max_user_watches.
Examples
Pick a port and open the browser
gio dev --port 4000 --openListen on this machine only
$ gio dev --host 127.0.0.1
GioJS 0.1.0-beta.8 (dev)
- Local: http://localhost:3000
- Network: not exposed (listening on loopback only; use --host 0.0.0.0)From a package.json script
{
"scripts": {
"dev": "gio dev",
"start": "gio start"
}
}Starters made by create-giojs run the server through cross-env NODE_ENV=development giojs-server instead (see giojs-server); both start the same server. With the Tailwind feature, keep npm run dev: it runs the Tailwind watcher next to the server, which gio dev alone does not.
A mistyped option
$ gio dev --prot 4000
gio: unknown option "--prot" - did you mean --port?
Run `gio dev --help` for usage.
$ echo $?
2Good to know
NODE_ENVfrom the shell is ignored:gio devalways runs development andgio startalways runs production.NODE_ENVin a.envfile is ignored too.- There is no build step before the server starts. Routes and client bundles are built at startup into
.gio/build, and.gio/routes.d.tsis rewritten. - The server binds its port only once the first worker is ready, so a request never reaches a server that cannot render yet.
- Exit codes:
0after a clean shutdown,1for a missing binary or when the server fails (its own code is passed through),2for a usage error.
Related
gio start- the same command in production modegio doctor- check the setup whengio devwill not start- Listen address and dev watcher settings in
gio.toml - Installation
- CLI overview
Version history
| Version | Changes |
|---|---|
v0.1.0-beta.8 | Introduced. Before, gio with no command started the server in whatever mode NODE_ENV named. |