{"id":19217,"library":"babel-plugin-transform-relative-paths","title":"babel-plugin-transform-relative-paths","description":"A Babel plugin that transforms relative import/require paths by adding an extra directory level (e.g., './' becomes '../', '../' becomes '../../'). Current stable version: 0.1.0. Release cadence is unknown. Differentiator: simple, no-config path manipulation for monorepos or code generators, but limited to single-level up transformation without custom configuration.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install babel-plugin-transform-relative-paths","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-transform-relative-paths","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-transform-relative-paths","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This plugin is a CJS module; ESM import may work in some environments but is not guaranteed.","wrong":"import plugin from 'babel-plugin-transform-relative-paths';","symbol":"default","correct":"module.exports = require('babel-plugin-transform-relative-paths');"},{"note":"String shorthand works only if the plugin is installed and Babel resolves it; explicit require is safer.","wrong":"plugins: ['babel-plugin-transform-relative-paths']","symbol":"plugin usage","correct":"plugins: [require('babel-plugin-transform-relative-paths')]"}],"quickstart":{"code":"// .babelrc\n{\n  \"plugins\": [\"transform-relative-paths\"]\n}\n\n// input.js\nimport someModule from './a-relative-path';\nimport someOtherModule from '../a-relative-path';\nconst someCommonModule = require('../../a-relative-path');\n\n// output.js (after transformation)\nimport someModule from '../a-relative-path';\nimport someOtherModule from '../../a-relative-path';\nconst someCommonModule = require('../../../a-relative-path');","lang":"javascript","description":"Demonstrates Babel plugin configuration and transformation of relative paths by adding one directory level."},"warnings":[{"fix":"Configure Babel to exclude node_modules via babel.config.js: module.exports = { plugins: [['transform-relative-paths']], only: ['./src'] };","message":"Plugin transforms all relative paths in import/require statements indiscriminately, including those from node_modules if not excluded.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"For custom transformations, consider using a different plugin or writing a custom one.","message":"Only supports moving paths up one level; cannot customize depth or transform in reverse.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure your require() calls use static string literals.","message":"Plugin does not handle dynamic requires or string concatenation in require() calls.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save-dev babel-plugin-transform-relative-paths","cause":"Plugin not installed or Babel cannot resolve it.","error":"Error: Cannot find module 'babel-plugin-transform-relative-paths'"},{"fix":"Use require('babel-plugin-transform-relative-paths') instead of import statement.","cause":"Using ES module import syntax with a CJS plugin that does not export a default function.","error":"TypeError: (0 , _plugin.default) is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}