Reputation: 35
I'm facing an issue in my React project, It works on Windows, but it does'nt work on my Ubuntu laptop. The error occurs when I'm performing the npm start. I have the error below for every redux actions and in src/common/routeConfig.js
Module not found: Error: You attempted to import /path/to/my/project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectSpread2
which falls outside of the project src/ directory.
Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
I've already tried the solution that told to use babel-preset-react-app-webpack-5 instead of babel-preset-react-app but nothing change (https://stackoverflow.com/a/67383306/12837824)
I'm using webpack 5 on a Rekit React app
Upvotes: 2
Views: 2788
Reputation: 377
For me, deleting node_modules
and re-run npm install
solved the problem. Sometimes weird things like this happened after system upgrade.
Upvotes: 1
Reputation: 1
Adding @babel/runtime and adding the following configs helped me resolve this issue.
Add these in your package.json
"nohoist": [
"**/babel-preset-react-app/@babel/runtime"
]
"presets": [
["react-app", { "absoluteRuntime": false }],
]
Upvotes: 0
Reputation: 26
I had the same issue inside my docker node:16.13, to fix it I had to do this command: yarn add @babel/runtime@7.5.1
to work with specific version 7.5.1 from @babel/runtime.
Upvotes: 1