{"id":12930,"library":"build-purescript","title":"PureScript Binary Builder","description":"The `build-purescript` Node.js module, currently at version 0.4.1, provides a programmatic interface for compiling the PureScript compiler binary (`purs`) directly from its source code. It handles the complete lifecycle, including downloading the PureScript GitHub repository, setting up the necessary Haskell toolchain via `stack`, and then compiling and installing the `purs` executable into the current working directory. The library exposes its operations as an Observable stream, allowing developers to subscribe to various progress events such as `download`, `setup`, and `build` completion, along with real-time output from the underlying `stack` commands. This detailed event reporting is a key differentiator, offering transparency and control over what is typically a complex and opaque build process for Haskell-based applications, making it suitable for automated build pipelines or environments requiring dynamic provisioning of specific PureScript compiler versions.","status":"active","version":"0.4.1","language":"javascript","source_language":"en","source_url":"https://github.com/shinnn/build-purescript","tags":["javascript","purs","purescript","request","executable","exe","bin","binary","build"],"install":[{"cmd":"npm install build-purescript","lang":"bash","label":"npm"},{"cmd":"yarn add build-purescript","lang":"bash","label":"yarn"},{"cmd":"pnpm add build-purescript","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only. Use 'require()' for synchronous import. It exports a single function as its default.","wrong":"import buildPurescript from 'build-purescript';","symbol":"buildPurescript","correct":"const buildPurescript = require('build-purescript');"},{"note":"The primary export is a default function, not a named export.","wrong":"import { buildPurescript } from 'build-purescript';","symbol":"buildPurescript","correct":"const buildPurescript = require('build-purescript');"}],"quickstart":{"code":"const {execFile} = require('child_process');\nconst buildPurescript = require('build-purescript');\n\nconsole.log('Starting PureScript compiler build...');\nbuildPurescript().subscribe({\n  complete() {\n    console.log('PureScript build completed. Verifying installation...');\n\n    execFile('./purs', ['--help'], (err, stdout) => {\n      if (err) {\n        console.error('Failed to run purs:', err);\n        return;\n      }\n      console.log('PURS help output (truncated):', stdout.toString().slice(0, 100) + '...');\n      console.log('PureScript binary successfully built and verified.');\n    });\n  },\n  error(err) {\n    console.error('PureScript build failed:', err);\n  },\n  next(event) {\n    console.log(`Event: ${event.id}`);\n    if (event.output) {\n      // Show the last line of output for progress indication\n      console.log(`  Output: ${event.output.trim().split('\\n').pop()}`);\n    } else if (event.response && event.response.bytes) {\n      console.log(`  Download progress: ${event.response.bytes} bytes received`);\n    }\n  }\n});","lang":"javascript","description":"This code snippet demonstrates how to programmatically build the PureScript compiler from source, subscribe to its progress events, and then verify the successful installation by executing the newly built `purs` binary."},"warnings":[{"fix":"Install `stack` globally on your system (e.g., `curl -sSL https://get.haskellstack.org/ | sh` on Linux/macOS) before attempting to use `build-purescript`.","message":"This package requires the `stack` CLI tool (a Haskell build system) to be pre-installed and available in the system's `$PATH` for the build process to succeed.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"After a successful build, manually move or symlink the `./purs` executable to a desired location in your system's PATH (e.g., `/usr/local/bin`) if you need global command-line access to `purs`.","message":"The compiled `purs` binary is placed directly in the current working directory (`process.cwd()`) where `build-purescript` is executed, not in a global or standard system executable path.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure your system has ample free disk space (several GBs), sufficient RAM (8GB+ recommended), and that standard development tools (like `gcc`, `make`, etc.) are installed to support the `stack` build environment.","message":"The PureScript compilation process is resource-intensive, involving the download and compilation of numerous Haskell packages. It requires a significant amount of disk space, RAM, and potentially C/C++ build tools.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Verify `stack` is installed (run `stack --version`). If not, install it via its official documentation. Ensure the `stack` executable's directory is included in your system's PATH environment variable.","cause":"The `stack` Haskell build tool is either not installed, not configured correctly, or not accessible in the system's PATH.","error":"Error: Command failed: stack setup"},{"fix":"Install `stack` globally (e.g., `curl -sSL https://get.haskellstack.org/ | sh`) and restart your terminal or ensure the `stack` executable's path is correctly configured in your PATH environment variable.","cause":"The `stack` Haskell build tool cannot be found by the system. This often means it's not installed or its installation directory is not in your system's PATH.","error":"Error: stack: command not found"},{"fix":"Review the build logs from `build-purescript` to confirm a successful compilation (look for the `build:complete` event). Ensure that any command attempting to execute `./purs` is run from the same directory where `build-purescript` was initially invoked.","cause":"The `purs` binary was not successfully generated in the current working directory, or the subsequent command attempting to run `./purs` is executed from a different path.","error":"Error: spawn ./purs ENOENT"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}