2

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

JeremsB
  • 35
  • 1
  • 6
  • and what does `npm start` do? (Or, is this _your_ code, or some generated code, like a create-react-app or the like. Remember to include [all those details in your post](/help/how-to-ask)). – Mike 'Pomax' Kamermans Sep 29 '21 at 22:17
  • `npm start` does not compile and provides me the error above. To add more details, It's a React app created with Rekit which use webpack 5. I don't really know wihich other part of my code I can put here because I dont' know what provide the error. Sorry in advance for maybe the bad quality of my post, I'm a newbie to StackOverflow. – JeremsB Sep 30 '21 at 20:36
  • Remember to not add details in comments: [update your post](/help/how-to-ask). And not by adding "update: ...", put them in your post so that it still reads as a single post. And if this is a project made with a generator tool (I'm not familiar with Rekit), explain what you did to get this error. E.g. you started from nothing, then what did you do? (what did you install, what commands did you run, which steps did you follow, etc). – Mike 'Pomax' Kamermans Sep 30 '21 at 21:08

3 Answers3

1

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.

1

For me, deleting node_modules and re-run npm install solved the problem. Sometimes weird things like this happened after system upgrade.

0

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 }],
  ]
Asvin
  • 1
  • 1