babel-preset-github

raw JSON →
3.2.1 verified Sat Apr 25 auth: no javascript maintenance

GitHub.com's official Babel preset for transpiling JavaScript. Current version 3.2.1 (released 2019, last updated 2019-08-08). Based on `@babel/preset-env` with curated set of plugins used by GitHub.com, including support for ES2018+ and some non-standard features. Targets GitHub's browser support matrix by default, but supports custom browserlist targets. Limited release cadence and narrow scope (primarily for internal GitHub usage). Minimal community adoption outside GitHub.

error Error: Cannot find module 'babel-preset-github'
cause Missing package installation or incorrect module resolution
fix
Run npm install --save-dev babel-preset-github @babel/core and ensure node_modules is intact.
error Error: [BABEL] Unknown presets: github
cause Preset name not resolved; Babel cannot find 'babel-preset-github' in node_modules
fix
Ensure the package is installed and .babelrc uses short name 'github' (not 'babel-preset-github').
error Error: Plugin/Preset files are not allowed to export anything but a function
cause Using an ES module import for babel-preset-github in a .babelrc.js file that expects CommonJS
fix
Use require() instead of import: const preset = require('babel-preset-github')
deprecated babel-preset-github is no longer actively maintained by GitHub; consider using @babel/preset-env directly with appropriate targets.
fix Switch to @babel/preset-env with 'github' browserlist (e.g. 'last 1 chrome version, last 1 firefox version, last 1 safari version')
gotcha The 'targets' option expects { browsers: array } format, not top-level array.
fix Use "presets": [["github", {"targets": {"browsers": ["last 1 version"]}}]]
gotcha Default browser targets are outdated and may not match GitHub's current browser support.
fix Specify explicit browserslist targets that match your project's requirements.
npm install babel-preset-github
yarn add babel-preset-github
pnpm add babel-preset-github

Shows how to configure babel-preset-github in .babelrc file with optional browserslist customization.

// Install: npm install --save-dev babel-preset-github @babel/core
// .babelrc
{
  "presets": ["github"]
}
// Or with custom browsers:
{
  "presets": [
    ["github", {
      "targets": {
        "browsers": ["last 2 versions", "not ie <= 11"]
      }
    }]
  ]
}