If you'd like to install BuckleScript globally, do:
npm install -g bs-platform
This gives you a few globally exposed commands you can run, described later. But usually, you'd install the project locally:
npm install --save-dev bs-platform
The commands that are exposed are:
bsb, the build system.
bsc, the raw compiler. Usually not used directly.
bsrefmt, the included Reason parser & printer.
Alternatives (Power Users)
Install From Source, Through NPM/Yarn
Prerequisite: either npm or yarn, plus the standard C toolchain.
git clone https://github.com/bucklescript/bucklescript cd bucklescript npm install
Install From Source, Without NPM/Yarn
Prerequisite: the standard C toolchain (gcc, make).
First, build the OCaml compiler:
git clone https://github.com/bucklescript/bucklescript cd bucklescript/vendor/ocaml ./configure -prefix `pwd` # put your preferred directory make world.opt make install
The patched compiler is installed locally into
$(pwd)/bin. To start using it temporarily, check if
ocamlopt.opt exist in
$(pwd)/bin, and temporarily add the location to your
Then, build BuckleScript itself:
cd ../../jscomp make world
At the end, you should have a binary called
jscomp/bin directory, which you can add to your
$PATH. You can also set an environment variable pointing to the standard library, e.g.
BSC_LIB=/path/to/jscomp/stdlib, for ease of use.
Warning: the built compiler is not relocatable out of box, don’t move it around unless you know what you're doing!