{"id":27187,"library":"nuclide-node-transpiler","title":"nuclide-node-transpiler","description":"A small Node.js module used internally by the Nuclide project to transpile JavaScript files from ES6+ to ES5 or ES6. v0.7.1 is the latest stable version. Release cadence is low; it is not actively updated outside of Nuclide. Key differentiator: it is designed specifically for Node.js server-side code, not for browser bundling, and integrates with Nuclide's module system.","status":"active","version":"0.7.1","language":"javascript","source_language":"en","source_url":"https://github.com/facebook/nuclide/tree/master/modules/nuclide-node-transpiler","tags":["javascript"],"install":[{"cmd":"npm install nuclide-node-transpiler","lang":"bash","label":"npm"},{"cmd":"yarn add nuclide-node-transpiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add nuclide-node-transpiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for Babel transpilation","package":"babel-core","optional":false},{"reason":"Provides Facebook-specific Babel presets","package":"babel-preset-fbjs","optional":false},{"reason":"Supports Flow type annotations","package":"babel-plugin-syntax-flow","optional":true}],"imports":[{"note":"The package uses ESM-style default export. CommonJS require will not work correctly if the module is transpiled.","wrong":"const transpile = require('nuclide-node-transpiler')","symbol":"default","correct":"import transpile from 'nuclide-node-transpiler'"},{"note":"Named export requires ESM import. CommonJS destructure will fail if the package is CJS-wrapped.","wrong":"const transpileFile = require('nuclide-node-transpiler').transpileFile","symbol":"transpileFile","correct":"import { transpileFile } from 'nuclide-node-transpiler'"},{"note":"Options object export for configuring Babel presets and plugins.","wrong":"","symbol":"options","correct":"import { options } from 'nuclide-node-transpiler'"}],"quickstart":{"code":"import transpile, { transpileFile, options } from 'nuclide-node-transpiler';\n\n// Transpile a string of code\nconst code = 'const x = (a) => a + 1;';\nconst result = transpile(code, { presets: ['@babel/preset-env'] });\nconsole.log(result.code);\n\n// Transpile a file\nconst fileResult = transpileFile('./file.js', { presets: ['@babel/preset-env'] });\nconsole.log(fileResult.code);\n\n// Use custom options\noptions.presets = ['@babel/preset-env'];\nconst customResult = transpile(code, options);\nconsole.log(customResult.code);","lang":"typescript","description":"Demonstrates basic usage of default export transpile() and named export transpileFile() with custom options."},"warnings":[{"fix":"Use @babel/core and @babel/preset-env with the package, but note that the package may not be compatible due to plugin/preset API changes.","message":"The package uses Babel 6 presets by default; Babel 7 presets are not supported.","severity":"breaking","affected_versions":">=0.0"},{"fix":"Replace with direct Babel usage: npm install @babel/core @babel/preset-env and use babel.transform or babel.transformFile.","message":"The package is deprecated in favor of using Babel directly.","severity":"deprecated","affected_versions":">=0.0"},{"fix":"Disable the automatic hook by setting the environment variable NUCLIDE_NODE_TRANSPILER_DISABLE=1.","message":"The package attempts to automatically transpile files during Node.js startup via require hook; this may interfere with other Babel configurations.","severity":"gotcha","affected_versions":">=0.0"},{"fix":"Clone the options object before passing if you need to reuse it: const result = transpile(code, Object.assign({}, options));","message":"The default export is a function that mutates the input options object; unexpected side effects may occur.","severity":"gotcha","affected_versions":">=0.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 --save-dev babel-preset-fbjs or include it in your project's dependencies.","cause":"Missing required Babel preset that is a dependency of nuclide-node-transpiler.","error":"Error: Cannot find module 'babel-preset-fbjs'"},{"fix":"Use the ESM import statement: import transpile from 'nuclide-node-transpiler'.","cause":"Using CommonJS require on an ESM-only export.","error":"TypeError: transpile is not a function"},{"fix":"Downgrade to Babel 6 plugins/presets or use a different transpilation tool.","cause":"Babel 7 plugin/preset format is incompatible with Babel 6 used by the package.","error":"Error: Plugin/Preset files are not allowed to export objects"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}