babel: Module not found: Can't resolve '@babel/runtime/helpers/esm/extends'
Bug Report
Current Behavior I created an app within a monorepo (Lerna) using yarn workspace and create-react-app (“react-scripts”: “2.0.0-next.3e165448”).
The architecture of the app is as follow:
- node_modules - @babel - core - runtime - etc… - other modules…
- package1 (shared components) - src - package.json
- package2 (the app consuming the shared components) - src - package.json
- package.json
Input Code
Calling
import _extends from '@babel/runtime/helpers/esm/extends';
from package2/index.js (or in any dependencies of package1) results in this error:
Module not found: Can't resolve '@babel/runtime/helpers/esm/extends'
Calling any other modules available under /node_modules works fine, even from @babel/core for instance:
import _default from '@babel/core/lib/tools/build-external-helpers';
works correctly.
Please note, if I replace @babel/runtime/… with the absolute path it would work.
Expected behavior/code Need to be able to call @babel/runtime/…
Babel Configuration (.babelrc, package.json, cli command) In the package.json root:
"babel": {
"presets": [
[
"@babel/preset-env"
]
],
"plugins": [
"@babel/plugin-transform-runtime"
]
},
Environment
- Babel version(s): @babel/runtime 7.4.2, @babel/core 7.4.0
- Node/npm version: Node v10.15.2
- OS: OS High Sierra 10.13.6
- Monorepo: yes, Lerna
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 26 (8 by maintainers)
I fixed mine by
We have met the same problem. Was there news about this ?
Same problem with MDX + Next. Tried a few recommended workaround – nothing helps.
We have finally managed to solve our issue, using react-app-rewired, customize-cra and a custom config. Thank your for your help Nicolo!