npm install @babel/compat-data
node -e "require('@babel/compat-data/corejs3-shipped-proposals')"
It should load the module as expected in Node.js 13.12
Error: Cannot find module '@babel/compat-data/corejs3-shipped-proposals'
Require stack:
- /tmp/[eval]
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:15)
at Function.resolve (internal/modules/cjs/helpers.js:78:19)
at [eval]:1:9
at Script.runInThisContext (vm.js:131:20)
at Object.runInThisContext (vm.js:297:38)
at Object.<anonymous> ([eval]-wrapper:10:26)
at Module._compile (internal/modules/cjs/loader.js:1123:30)
at evalScript (internal/process/execution.js:94:25)
at internal/main/eval_string.js:23:3 {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/tmp/[eval]' ]
}
Caught by the Babel CI: https://travis-ci.com/github/babel/babel/jobs/319348116#L360
The regression was likely introduced in https://github.com/nodejs/node/pull/32351.
The file structure of @babel/compat-data
can be simplified w.l.o.g as
package.json
corejs3-shipped-proposals.js
data/corejs3-shipped-proposals.json
and the package.json
:
"exports": {
"./corejs3-shipped-proposals": "./data/corejs3-shipped-proposals.json"
}
The corejs3-shipped-proposals.js
is a proxy which delegates to "./data/corejs3-shipped-proposals.json" for Node.js < 13.3 support.
module.exports = require("./data/corejs3-shipped-proposals.json");
/cc @guybedford
@JLHwung I created https://github.com/babel/babel/pull/11283 specifically to avoid Babel having this error. Was the above fix not patched and released already?
@guybedford Ahh thanks. It was release in 7.9.0.
For those babel users who are affected by this issue after upgrading to node.js 13.13/12.17, please upgrade @babel/preset-env
to 7.9.0.
Great, I'm glad the early fix here could help!
I had this problem in building a React Native Bob library. I solved it using nvm install 13.12
, which downgraded my node to 13.12
.
This solution only applies if you use nvm
to manage your Node versions (if you don't I recommend it!)
FYI, I noticed the same issue in 12.17.x
. We have to switch to 12.6.x
in Travis for now.
Most helpful comment
@guybedford Ahh thanks. It was release in 7.9.0.
For those babel users who are affected by this issue after upgrading to node.js 13.13/12.17, please upgrade
@babel/preset-env
to 7.9.0.