{"id":25802,"library":"js2coffee","title":"js2coffee","description":"JavaScript to CoffeeScript compiler. v2.2.0 (latest) rewrites the 0.x series with a new Esprima-based parser, offering better JavaScript coverage. Released on npm and Bower. Key differentiator: unidirectional conversion from JS to CoffeeScript with warnings for unrepresentable patterns.","status":"maintenance","version":"2.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/js2coffee/js2coffee","tags":["javascript","coffeescript","language","compiler"],"install":[{"cmd":"npm install js2coffee","lang":"bash","label":"npm"},{"cmd":"yarn add js2coffee","lang":"bash","label":"yarn"},{"cmd":"pnpm add js2coffee","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"JavaScript parser used to parse input","package":"esprima","optional":false}],"imports":[{"note":"CommonJS only. Use require() or window.js2coffee for browser.","wrong":"import js2coffee from 'js2coffee' (ESM not supported)","symbol":"js2coffee","correct":"const js2coffee = require('js2coffee')"},{"note":"build is the main API method returning { code, ast, map, warnings }","wrong":"js2coffee(source)","symbol":"build","correct":"js2coffee.build(source)"},{"note":"Read-only property exposing library version","symbol":"version","correct":"js2coffee.version (string)"}],"quickstart":{"code":"const js2coffee = require('js2coffee');\nconst source = `\nvar x = 1;\nfunction hello(name) {\n  console.log('Hello, ' + name);\n}\nhello('world');\n`;\nconst result = js2coffee.build(source);\nconsole.log(result.code);\n// x = 1\n// hello = (name) ->\n//   console.log 'Hello, ' + name\n// hello 'world'","lang":"javascript","description":"Compile JavaScript to CoffeeScript using the build method, outputting CoffeeScript code."},"warnings":[{"fix":"Use `js2coffee.build()` instead of the old `js2coffee.js2coffee()`","message":"2.0 release rewrites API: 0.x `js2coffee.js2coffee()` no longer works","severity":"breaking","affected_versions":">=2.0"},{"fix":"Upgrade to v2.x using the migration guide","message":"0.x series is deprecated. No longer supported.","severity":"deprecated","affected_versions":"<2.0"},{"fix":"Check result.warnings array after conversion and handle accordingly","message":"Not all JavaScript constructs convert cleanly; result.warnings may contain warnings for unrepresentable patterns","severity":"gotcha","affected_versions":">=2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"npm install js2coffee","cause":"Package not installed","error":"Cannot find module 'js2coffee'"},{"fix":"Use js2coffee.build() instead of trying to call js2coffee()","cause":"v2.x does not have a default export","error":"js2coffee is not a function"},{"fix":"Update to js2coffee.build() for v2","cause":"0.x API does not exist in v2","error":"require(...).js2coffee is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}