{"id":19367,"library":"babel-standalone","title":"babel-standalone","description":"babel-standalone provides a standalone build of Babel (v6.26.0) for use in non-Node.js environments, primarily browsers. It bundles all standard Babel plugins and presets, including an optional babili (babel-minify) build. Unlike the Babel CLI or module-based usage, this package requires no build step — it exposes a global Babel object and can automatically transpile script tags with type=\"text/babel\" or \"text/jsx\". It is ideal for REPLs, JSFiddle-like sites, or embedding JavaScript scripting in apps. Note that this is based on Babel 6; Babel 7+ has its own @babel/standalone package with a different API.","status":"deprecated","version":"6.26.0","language":"javascript","source_language":"en","source_url":"https://github.com/Daniel15/babel-standalone","tags":["javascript","babel","babeljs","6to5","transpile","transpiler"],"install":[{"cmd":"npm install babel-standalone","lang":"bash","label":"npm"},{"cmd":"yarn add babel-standalone","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-standalone","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is intended for browsers and adds Babel as a global. In Node.js, use @babel/core instead. For ESM imports in modern bundlers, consider @babel/standalone.","wrong":"const Babel = require('babel-standalone')","symbol":"Babel","correct":"<script src=\"https://unpkg.com/babel-standalone@6/babel.min.js\"></script>"},{"note":"The transform method is called on the global Babel object. Options must include presets or plugins; omitting them results in no transformation.","wrong":"Babel.transform(code)","symbol":"transform","correct":"Babel.transform(code, options)"},{"note":"Registers a custom plugin for use in subsequent transforms. The plugin name is then used in presets/plugins options. Available in v6.22+.","wrong":"","symbol":"registerPlugin","correct":"Babel.registerPlugin('pluginName', pluginFunction)"}],"quickstart":{"code":"<!DOCTYPE html>\n<html>\n<body>\n<script src=\"https://unpkg.com/babel-standalone@6/babel.min.js\"></script>\n<script type=\"text/babel\">\nconst getMessage = () => \"Hello World\";\ndocument.write(getMessage());\n</script>\n</body>\n</html>","lang":"javascript","description":"Loads babel-standalone from CDN and uses inline script tag with type text/babel to automatically transpile ES2015 arrow function."},"warnings":[{"fix":"Switch to @babel/standalone. Update script source to https://unpkg.com/@babel/standalone/babel.min.js and adjust API usage (e.g., Babel.transform -> Babel.transformSync).","message":"babel-standalone is based on Babel 6, which is deprecated in favor of Babel 7+. Use @babel/standalone for newer features and security updates.","severity":"deprecated","affected_versions":"*"},{"fix":"Ensure code inside script tags handles asynchronous execution if needed, or switch to explicit Babel.transformSync.","message":"In v6.24.0, the automatic execution of script tags with type text/babel was fixed to work with async transforms. Users relying on synchronous behavior may break.","severity":"breaking","affected_versions":">=6.24.0"},{"fix":"Specify presets in the script tag: <script type=\"text/babel\" data-presets=\"es2015\"> or in Babel.transform({presets: ['es2015']}).","message":"The package does not load .babelrc files; all presets/plugins must be specified inline via data-attributes or in the transform options.","severity":"gotcha","affected_versions":"*"},{"fix":"Upgrade to v6.24.0+ or use inline scripts only.","message":"Script tags with external src attribute may not work as expected in older browsers; XHR fallback might be needed.","severity":"gotcha","affected_versions":"<6.24.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Load babel-standalone script before any script that references Babel. Ensure the URL is correct: <script src=\"https://unpkg.com/babel-standalone@6/babel.min.js\"></script>","cause":"Library not loaded or loaded after script calling Babel.","error":"Babel is not defined"},{"fix":"Verify the CDN URL or download the file and host locally. Use a reliable CDN like unpkg or cdnjs.","cause":"Babel is not loaded (likely due to network issue or wrong CDN URL).","error":"Uncaught TypeError: Cannot read property 'transform' of undefined"},{"fix":"Pass preset in options: Babel.transform(input, { presets: ['es2015'] }) or use data-presets=\"es2015\" in script tags.","cause":"Preset not specified correctly; babel-standalone does not read .babelrc.","error":"Module build failed: Error: Couldn't find preset \"es2015\" relative to directory"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}