deno install [OPTIONS...] [URL] [SCRIPT_ARGS...]
will install the script
available at URL
under the name EXE_NAME
.
This command creates a thin, executable shell script which invokes deno
using
the specified CLI flags and main module. It is placed in the installation root’s
bin
directory.
Example:
To change the executable name, use -n
/--name
:
deno install --allow-net --allow-read -n serve https://deno.land/std@$STD_VERSION/http/file_server.ts
- Attempt to take the file stem of the URL path. The above example would become ‘file_server’.
- If the file stem is something generic like ‘main’, ‘mod’, ‘index’ or ‘cli’, and the path has no parent, take the file name of the parent path. Otherwise settle with the generic name.
- If the resulting name has an ‘@…’ suffix, strip it.
To change the installation root, use :
The installation root is determined, in order of precedence:
--root
option$HOME/.deno
These must be added to the path manually if required.
echo 'export PATH="$HOME/.deno/bin:$PATH"' >> ~/.bashrc
You must specify permissions that will be used to run the script at installation time.
For good practice, use the idiom to specify the entry point in an executable script.
Example:
// https://example.com/awesome/cli.ts
async function myAwesomeCli(): Promise<void> {
}
if (import.meta.main) {
myAwesomeCli();
}
When you create an executable script make sure to let users know by adding an example installation command to your repository:
You can uninstall the script with deno uninstall
command.
$ deno uninstall file_server
deleted /Users/deno/.deno/bin/file_server