Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including babel-root-slash-import with all npm packages installed. Try it out:

var babelRootSlashImport = require("babel-root-slash-import")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

babel-root-slash-import v3.1.0

Babel Plugin to enable relative root-import

Babel Root Import

Babel plugin to add the opportunity to use import with root based paths.


// Usually
import SomeExample from '../../../some/example.js';

// With Babel-Root-Importer
import SomeExample from '/some/example.js';


npm install babel-root-slash-import --save-dev


Add a .babelrc file and write:

  "plugins": [

or pass the plugin with the plugins-flag on CLI

babel-node myfile.js --plugins babel-root-slash-import


If you want a custom root because for example all your files are in the src/js folder you can define this in your .babelrc file

  "plugins": [
    ["babel-root-slash-import", {
      "rootPathSuffix": "src/js"


If you like this project just give it a star :) I like stars.


Forked use / instead of '~/' to define the root. This is to go with the Meteor's ES2015 module implementation.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free