Compiling and Running Code
Agency code compiles down to plain JavaScript and runs on Node.
Running a file
agency run foo.agencyThis compiles the file and immediately executes its main node. run is also the default command:
agency foo.agencySee the run CLI reference for a couple of extra options.
Compiling to JavaScript
Use compile (also aliased as build):
agency compile foo.agency
agency compile lib/You can pass multiple files or directories. A couple of handy flags:
--ts— emit.tsfiles instead of.js.-w, --watch— recompile automatically whenever the inputs change.
The compile CLI reference has the full list.
The global-install gotcha
If you installed Agency globally (npm install -g agency-lang), there's a classic Node trap to watch out for. A global install makes the agency CLI available everywhere, but the agency-lang package isn't importable everywhere.
So if you compile and run separately, you may see an error like this:
agency compile foo.agency
node foo.js
# Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'agency-lang'Two easy fixes:
Use
agency runinstead ofnode.runtells Node where to find theagency-langpackage.bashagency run foo.agencyIf you're inside an npm project, install
agency-langfor the project.
Or you can create a standalone script with agency pack. This will inline Agency and other related packages, so all you need to is Node (a lesser-known Beatles song).