{"id":26007,"library":"node.bf","title":"node.bf","description":"Node.bf is a JavaScript transpiler that compiles Node.js modules written in Brainfuck, an esoteric Turing-complete language using only characters +-<>[].,. Version 0.1.0 is the current stable release; the project appears to be in early development with no frequent updates. Unlike other Brainfuck interpreters or compilers, node.bf integrates with Node.js module system, allowing .bf files to be compiled into JavaScript modules that export a function. It uses Jison for parser generation and supports Webpack loaders for direct import of .bf files.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install node.bf","lang":"bash","label":"npm"},{"cmd":"yarn add node.bf","lang":"bash","label":"yarn"},{"cmd":"pnpm add node.bf","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"parser generator used to build the lexer/parser from grammar","package":"jison","optional":false},{"reason":"used in development for bundling and custom loaders","package":"webpack","optional":true}],"imports":[{"note":"Compiled .bf files export a default function. Direct require may not work without Webpack loader.","wrong":"const myModule = require('./path/to/module.bf');","symbol":"default import (compiled function)","correct":"import myModule from './path/to/module.bf';"},{"note":"ESM is preferred; CJS require works but check exports map.","wrong":"const compile = require('node.bf').compile;","symbol":"compile function (from node.bf package)","correct":"import { compile } from 'node.bf';"},{"note":"run may be available; refer to docs for exact exports.","wrong":"import { run } from 'node.bf/src';","symbol":"run function (if exported)","correct":"import { run } from 'node.bf';"}],"quickstart":{"code":"import { compile } from 'node.bf';\nconst fs = require('fs');\nconst path = require('path');\n\nconst bfSource = '++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.';\n\n// Compile the Brainfuck source to a JavaScript function\ntranspile(bfSource).then(jsCode => {\n  // Create a Node module from the compiled code\n  const modulePath = path.join(process.cwd(), 'hello.bf.js');\n  fs.writeFileSync(modulePath, `module.exports = function(input) { ${jsCode} };`);\n  const helloWorld = require('./hello.bf.js');\n  console.log(helloWorld(''));\n});\n\nfunction transpile(source) {\n  return new Promise((resolve, reject) => {\n    compile(source, (err, result) => {\n      if (err) reject(err);\n      else resolve(result);\n    });\n  });\n}","lang":"javascript","description":"Shows how to compile a Brainfuck 'Hello World' program and use the resulting function with Node.js modules."},"warnings":[{"fix":"Check documentation for the exact API signature. Use a callback wrapper or check if .compile() returns a Promise.","message":"The compile function may require a callback; some versions might return a Promise.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Either compile .bf files via API first or configure Webpack with node-bf loader.","message":"Direct require of .bf files without Webpack configuration will not work; you must either compile manually or use the custom loader.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use compile and create the module wrapper yourself, or check exports list.","message":"Missing export 'run'? Some builds might not export 'run'.","severity":"broken","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install node.bf' and ensure it's in package.json dependencies.","cause":"Package not installed or incorrectly referenced.","error":"Cannot find module 'node.bf'"},{"fix":"Use node.bf compiler to transpile .bf file to .js before running.","cause":"Attempting to run .bf file directly with Node without compiling.","error":"SyntaxError: Unexpected token >"},{"fix":"Use correct import: import { compile } from 'node.bf' or const compile = require('node.bf').compile.","cause":"Import/require syntax wrong or compile not exported.","error":"TypeError: compile is not a function"},{"fix":"Ensure the function receives a string input for the Brainfuck program's input tape.","cause":"Calling compiled function with non-string argument.","error":"Error: Input must be a string"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}