Error: Package exports for <path to project folder>/node_modules/@babel/helper-compilation-targets' do not define a '.' subpath

Had the same issue. Updating the node.js fixed that for me


It will be fixed on babel v7.8.4, see https://github.com/babel/babel/pull/11006. Before a new babel release is cut, please upgrade node.js to >=13.2.0, which incorporates the necessary upstream fix.

Note that node.js 12 is not affected unless you have manually toggled on --experimental-modules flag. If that is the case, please also upgrade node.js to >=13.2.0.


So this seems to be an incompatibility between Babel and Node.js. The general solution is to switch to nodejs 12 (e.g. if you are using nvm), since it only affected nodejs 13:

nvm install 12
nvm use 12

However, for my Rails 6 application this was not sufficient alone, as I still got the same error. Telling Yarn about the node version I am expecting to use was necessary in addition to that. So I added this to the package.json:

"engines": {
  "node": "12.14.1"
}