{"id":25160,"library":"decafjs","title":"Decaf JS","description":"A CoffeeScript to ES6 transpiler that leverages the CoffeeScript compiler to produce modern JavaScript syntax. Stable version 0.6.2 is available on npm. Unlike other transpilers, Decaf uses the official CoffeeScript parser to build an AST and then maps it to ES6 constructs, falling back to original CoffeeScript output for unsupported syntax. It can be used as a CLI tool or as a Node module with jscodeshift for code transforms. Development appears to be in maintenance mode with limited recent updates.","status":"maintenance","version":"0.6.2","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/juliankrispel/decaf","tags":["javascript"],"install":[{"cmd":"npm install decafjs","lang":"bash","label":"npm"},{"cmd":"yarn add decafjs","lang":"bash","label":"yarn"},{"cmd":"pnpm add decafjs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for parsing CoffeeScript syntax","package":"coffeescript","optional":false},{"reason":"Builds esprima-compatible syntax tree from CoffeeScript AST","package":"ast-types","optional":false},{"reason":"Used for printing JavaScript AST to code","package":"recast","optional":false}],"imports":[{"note":"Package does not provide ES module exports; use CommonJS require.","wrong":"import decaf from 'decafjs';","symbol":"default","correct":"const decaf = require('decafjs');"},{"note":"The module exports a single function object; compile is a property, not a named export.","wrong":"import { compile } from 'decafjs';","symbol":"compile","correct":"const decaf = require('decafjs'); decaf.compile('()-> alert \"hello\"');"},{"note":"Not available as named export; the main default export contains all methods.","wrong":"const { compileFile } = require('decafjs');","symbol":"compileFile","correct":"const decaf = require('decafjs'); decaf.compileFile('file.coffee');"}],"quickstart":{"code":"const decaf = require('decafjs');\nconst path = require('path');\nconst fs = require('fs');\n\n// Compile a CoffeeScript string to ES6 JS\nconst coffeeCode = 'square = (x) -> x * x';\nconst es6Code = decaf.compile(coffeeCode);\nconsole.log(es6Code); // outputs: var square = (x) => x * x;\n\n// Compile a file (assuming example.coffee exists)\nconst filePath = path.join(__dirname, 'example.coffee');\nconst coffeeFromFile = fs.readFileSync(filePath, 'utf8');\nconst jsFromFile = decaf.compile(coffeeFromFile, { tabWidth: 2 });\nfs.writeFileSync('example.js', jsFromFile);\nconsole.log('Compiled successfully!');","lang":"javascript","description":"Demonstrates basic usage: compile CoffeeScript string and file to ES6 JavaScript using Decaf."},"warnings":[{"fix":"Install with 'npm install decafjs'.","message":"The package name on npm is 'decafjs', not 'decaf'. Using 'npm install decaf' installs a different unrelated package.","severity":"gotcha","affected_versions":"all"},{"fix":"Use: const decaf = require('decafjs'); then decaf.compile(...).","message":"The exported object is the compile function itself; you cannot destructure named exports like { compile }.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider alternatives like decaffeinate (more actively maintained).","message":"Package has not been updated since 2018; may not support latest CoffeeScript or ES6 features.","severity":"deprecated","affected_versions":"0.6.2"},{"fix":"Run: npm install -g decafjs; then decaf <file or directory>.","message":"When used as CLI globally, command is 'decaf' not 'decafjs'. Ensure global install.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install: npm install coffeescript (or coffee-script for older versions).","cause":"Missing peer dependency coffee-script / coffeescript.","error":"Error: Cannot find module 'coffee-script'"},{"fix":"Use: const decaf = require('decafjs'); decaf.compile(...);","cause":"Incorrect import/require: probably using import or destructuring.","error":"TypeError: decaf.compile is not a function"},{"fix":"Check source for syntax errors; Decaf falls back to original CoffeeScript output, but invalid syntax will still break.","cause":"Input contains unsupported CoffeeScript syntax or invalid input.","error":"SyntaxError: Unexpected token while parsing CoffeeScript"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}