I just created a new project folder and ran the following commands:
Created index.js with express imported and views for a sample jsx file. When I run on localhost, I get this error:
Error: Package exports for '<path_to_project_folder>/node_modules/@babel/helper-compilation-targets' do not define a '.' subpath
at applyExports (internal/modules/cjs/loader.js:485:15)
at resolveExports (internal/modules/cjs/loader.js:508:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:577:20)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:879:27)
at Function.Module._load (internal/modules/cjs/loader.js:785:27)
at Module.require (internal/modules/cjs/loader.js:956:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (<path_to_project_folder>/node_modules/@babel/preset-env/lib/debug.js:8:33)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Module._compile (<path_to_project_folder>/node_modules/pirates/lib/index.js:99:24)
In Oct 2019, I created an express app using the same steps ran, and found there is no such package (@babel/helper-compilation-targets), and it ran fine.
I'm not sure what is wrong. Can anyone help to advice? Thank you!
Had the same issue. Updating the node.js fixed that for me
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"
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With