import a module from node_modules with babel but failed

See the babel docs:

NOTE: By default all requires to node_modules will be ignored. You can override this by passing an ignore regex.

Generally the expectation is that modules in node_modules will already have been transpiled ahead of time, so they are not processed by Babel. If you will not be doing that, then you need to tell it what files it can process. ignore allows that.

require("babel/register")({
    // Ignore everything in node_modules except node_modules/rcomponents.
    ignore: /node_modules\/(?!rcomponents)/
});

Leave a Comment