You need Node, Yarn (or npm) and watchman.
node -vshould be >= 24.14.1- We recommend that you use
nvmto install a specific Node.js version. Optionally, you can also set up its automatic version switching shell integration.
- We recommend that you use
yarn --versionshould be the in-tree4.13.0version. See instructions on how to use it on your OS. For example, you might need to run:corepack enable.
You also need a C compiler:
- Linux: GCC 4.6 or later
- OS X: Xcode 5.0 or later
Add the following to your /etc/wsl.conf if not yet present. This prevents WSL from regenerating the /etc/hosts as well as the /etc/resolv.conf:
[network]
generateResolvConf=false
generateHosts = false
Previously, using Windows Subsystem for Linux required remapping localhost to the IPv6
loopback address in /etc/hosts, because webpack-dev-server binds ::1 only
(webpack.config.js) and src/server/server.js used to proxy to it by the localhost
hostname — which on stock WSL resolves only to 127.0.0.1, causing ECONNREFUSED.
src/server/app.js now targets the literal [::1] address instead, so this is
no longer required for yarn run dev to work. If you still hit other WSL networking issues, you may
need to add the following to your /etc/hosts:
::1 ip6-localhost ip6-loopback localhost
A bit newer version of watchman is now required and 4.9.0 is no longer supported. Working versions include at least
- 20220320.140531.0
- 20240407.093313.0
brew install watchman
It's possible to run prebuilt binaries from some release with these instructions or in some systems to build the binaries from code following these instructions.
yarn install
- OSX / Linux:
yarn run dev - open: http://localhost:8080
yarn run dev runs scripts/dev.sh, which starts Relay, the Express dev server (node --watch),
webpack-dev-server, the SVG sprite watcher (yarn sprites --watch) and yarn packages-watch (lerna run watch --stream --concurrency 12)
in parallel. packages-watch builds every digitransit-component, digitransit-store
and digitransit-search-util package once and then keeps watching/rebuilding them, so a manual
yarn setup/yarn packages-build is not required beforehand.
Lerna ignores --parallel because nx.json has targetDefaults, so --concurrency must be at
least the number of packages with a watch script (currently 12); with fewer, the rest never
start, since a watcher never finishes. Nx is pinned to 23.2.0 in resolutions: from 23.3.0 on,
Lerna's --stream is ignored and the output is replaced by Nx's task spinner.
There's also a lighter-weight yarn dev-nowatch, which only runs the Express dev server and
webpack-dev-server (no Relay/package watchers). Since it skips packages-watch, on a
fresh clone you must run yarn packages-build yourself first, or webpack fails with
Module not found errors for @digitransit-component/*/@digitransit-search-util/*/
@digitransit-store/* packages. It also doesn't populate _static, so run yarn static and
yarn sprites first too.
- First run:
yarn run setup, thenyarn run build, then run:yarn run start - open: http://localhost:8080
While yarn run dev is running, changes to files in digitransit-component, digitransit-store
and digitransit-search-util (including its query-utils Relay queries, which are also watched by
a dedicated relay-compiler --watch in scripts/dev.sh) are picked up automatically by live
watchers and rebuilt in the background — no manual rebuild step is needed.
- run:
CONFIG=hsl NODE_ENV=production node node_modules/.bin/webpack --json > _static/digitransit.json - run:
yarn webpack-bundle-analyzer _static/digitransit.json
Husky (npm-package) is used for setting up the git hooks (.git/hooks/) that will allow custom scripts to be run on the repository.
Look up 'husky' in package.json to see the details.
Digitransit ui can be configured in multiple ways. You can
- Change between National and Regional versions using
CONFIGparameter- Alternatively, use
BASE_CONFIGif server is supposed to serve multiple configurations which have same base configuration. It is used server side at start up and request's host specific config based onhostorx-forwarded-hostheader is merged into it before returning config to client.
- Alternatively, use
- Switch API backend using
API_URLparameter
Note that you can combine multiple configuration parameters.
RUN_ENV(development/production) — deployment tier. Server-only env var; read during config assembly to pick dev vs prod backends and mirrored intowindow.configfor the client. Check it viaisDevRunEnv(config)(src/server/utils/envUtils.js, see its JSDoc for details).yarn devsetsRUN_ENV=development; deployments set it via Kubernetes /-e RUN_ENV=….NODE_ENV(development/production) — build mode;'development'only for the localyarn devserver / a dev bundle. Not the deployment tier — one production bundle runs on every tier; useRUN_ENV/isDevRunEnvfor that. Always check it via a literalprocess.env.NODE_ENVcomparison written inline (=== 'development',!== 'production', etc.), not through an imported/computed constant — seedocs/Webpack.mdfor why.
Start national version
yarn run buildyarn run start
Start HSL version
yarn run buildCONFIG=hsl yarn run start
By default digitransit-ui uses services from https://dev-api.digitransit.fi but you can override API server like so:
yarn run buildAPI_URL=https://api.digitransit.fi yarn run start
If you want to specify different URL (not just base URL) for individual services, you can define variables OTP_URL, MAP_URL and/or GEOCODING_BASE_URL (URL path before /search or /reverse).
yarn run buildGEOCODING_BASE_URL=https://api.digitransit.fi/geocoding/v1 OTP_URL=https://api.digitransit.fi/routing/v2/finland/ yarn run start
These are API endpoint base URLs rather than web pages, and require an API key. See the Digitransit API documentation.
STATIC_MESSAGE_URL=https://dev-yleisviesti.digitransit.fi yarn run start