Configuring a Repl
Configuring a Repl
A file named .replit
can be added to any repl in order to customize the behavior of the repl. Used in combination with nix for installed linux packages, the sky is the limit! Written in toml, a .replit
file looks something like:
Here's a short video on how to use the .replit
file or read the text explanation below.
In the snippet above, run
is a string which will be executed in the shell whenever you hit the "Run" button. The language
helps the IDE understand how to provide features like packaging and code intelligence. This is normally configured for you when you clone from a Git repository.
Here is an example of a repl using .replit
to print "hello world" instead of running the code:
Configuring a Cloned Repl
When you clone a repository without a .replit
file, we automatically show the visual .replit
editor:
This will automatically create the .replit
file and make it possible to customize how the repl will run. You can use the shell to run any command and then set the "Run" button once you've decided what it should do. Clicking "done" will finalize the repl's configuration and close the visual editor. It's always possible to make changes later by visiting the .replit
file from the filetree. Adding .replit
to a repository makes cloning fast with no configuration necessary.
Other Configuration
The .replit
file can also provide other configuration hints. The full specification is provided below:
run
: Command - Command that is executed when the run button is clickedlanguage
: ReservedonBoot
: Command - Command that is executed once when the repl first starts upaudio
: Boolean - Whether system-wide audio is enabled for this repl.packager
: Package management configuration.afterInstall
: Command - Command that is executed after a new package is installedignoredPaths
: List of Strings - List of paths to ignore while attempting to guess packages (More about installing packages)ignoredPackages
: List of strings - List of modules to never attempt to guess a package for, when installing packages (More about installing packages)language
: String - Specified the language to use for package operations. See available languages in the Universal Package Manager repository.features
: UPM features that are supported by the specified languages.packageSearch
: Boolean - If enabled, a package search panel will be available in the sidebar.guessImports
: Boolean - If enabled, UPM will attempt to guess which packages need to be installed prior to running the repl.
languages.<language name>
: Per-language configuration. The language name has no special meaning other than to allow multiple languages to be configured at once.pattern
: String - A glob used to identify which files belong to this language configuration. (Example:**/*.js
)languageServer
: Configuration for setting up LSP for this language. This allows for code intelligence (autocomplete, underlined errors, etc...)start
: Command - The command used to start the LSP server
Command
A command can either be a string or a list of strings. If the command is a string ("node index.js"
), it will be executed via sh -c "<command>"
. If the command is a list of strings (["node", "index.js"]
), it will be directly executed with the list of strings passed as arguments. When possible, it is preferred to pass a list of strings.
Example .replit File
HTML
For HTML projects, you can keep the run command empty and we will serve the project for you automatically. As per web standards, the entrypoint file is index.html
. If you want to serve a different file, you can roll your own webserver in one of the languages that we support.
We created an example for you in NodeJS that serves foo.html
instead of index.html
. Otherwise it works like any other HTML project.
Node.js .replit
.replit
Last updated