Change to which directory Babel plugins are allowed?

I get this error:

An unknown plugin "properties-transformations-properties" specified in the "base" at 0, tried to resolve relative to "/ home / me / Projects / myproj / src"

The message is pretty clear, so I know why this is happening, but I want to change where Babel is looking for plugins / presets / packages.

I am using Babel with rollup through rollup-plugin-babel .

The options that I give them are as follows:

{ plugins: [ 'transform-class-properties', 'transform-object-rest-spread' ], babelrc: false } 

However, I cannot find an option to change where Babel is looking for plugins. Is there no way to do this without rewriting my list of plugins to use absolute paths?


I also cannot find a public API method for extracting dependencies from .babelrc , so it’s rather difficult to manually rewrite the file to use full paths. Notabene Babel configurations can also be saved in package.json, and there was some talk of adding support for .babelrc.js too - I really don't want to support my own project, which is looking for all the different places where the babel configuration can hide, parse the file and scan it for all plugins with and without any babel-plugin- .

+7
babeljs rollupjs
source share
1 answer

You can use NODE_PATH to do the same.

 $ npx babel test.js Unknown plugin "external-helpers" specified in "/Users/tarun.lalwani/Desktop/babeltest/.babelrc" at 0, attempted to resolve relative to "/Users/tarun.lalwani/Desktop/babeltest" 

After specifying the path for the modules elsewhere

 $ NODE_PATH=/Users/tarun.lalwani/Desktop/babeltest2/node_modules npx babel test.js function test() { this.abc = function (url) { return console.log(url); }; } 

NODE_PATH environment variable allows you to specify additional locations where you can search for modules

+2
source share

All Articles