0

my problem is that i am getting this error when i run my react-app with docker image. When i am not running my react app with docker image works fine. I have seen a lot of stuff on stack Overflow but none of this solved my problem.

I am using babel version < 7 specific is 6.26.0

I have tried to upgrade my babel version to 7 with this instructions, also i have tried this but it's not solve my problem.

Can anyone help me with this?

burrito
  • 143
  • 1
  • 2
  • 11
  • can you share your babel config file? I would like to check your plugins and presets. – Burak Ayyildiz Nov 08 '22 at 11:17
  • `{ "presets": [ "es2015", "react", "stage-2" ], "plugins": [ "transform-object-rest-spread", "transform-object-assign", ["import", { "libraryName": "antd", "style": true }] // ["import", { "libraryName": "antd", "style": "css" }] ] }` – burrito Nov 08 '22 at 11:22
  • just to make sure, can you add @babel/transform-runtime" in the plugins? at least this is how it worked on my side. And can you verify that you have the same node version onn docker and vice versa? – Burak Ayyildiz Nov 08 '22 at 11:25
  • @BurakAyyildiz can you be more specific on how to add `@babel/transform-runtime` in the plugins. I `npm install` this but nothing show up in the `babelrc` file. Also you mean if i have the same version on my computer with the node version that i give to docker? – burrito Nov 08 '22 at 11:31
  • Yes correct, check the node versions on your local machine and the one on docker. e.g for the babelrc add it like this: { "presets": [ "es2015", "react", "stage-2" ], "plugins": [ "@babel/plugin-transform-runtime", "transform-object-rest-spread", "transform-object-assign", ["import", { "libraryName": "antd", "style": true }] // ["import", { "libraryName": "antd", "style": "css" }] ] } – Burak Ayyildiz Nov 08 '22 at 11:37
  • Yes i give the same `node version`, also i get this error when i change the `babelrc file`: `ReferenceError: Unknown plugin "@babel/plugin-transform-runtime" specified in "/web_app/.babelrc" at 0` – burrito Nov 08 '22 at 11:47
  • please install the package like: `npm install --save-dev @babel/plugin-transform-runtime` and `npm install --save @babel/runtime` – Burak Ayyildiz Nov 08 '22 at 12:08
  • @BurakAyyildiz now i am getting `Uncaught ReferenceError: exports is not defined` – burrito Nov 08 '22 at 12:24
  • Now you have different errors, import other babel plugins. Look for solutions in the internet now. – Burak Ayyildiz Nov 08 '22 at 13:09

1 Answers1

0

With the help of Burak Ayyildiz, i solve my problem. I just install babel-plugin-transform-runtime with this command: npm i babel-plugin-transform-runtime (I am using babel<7). Also on the babelrc file i add this on plugins: "transform-runtime"

burrito
  • 143
  • 1
  • 2
  • 11