1

I get the following error the moment I install @babel/preset-env and try running a node.js file.

Requires Babel "^7.0.0-0", but was loaded with "6.26.3"

Following is the stack trace

(While processing preset: "P:\\Projects\\ReactNative\\apc-c\\node_modules\\@babel\\preset-env\\lib\\index.js")
    at throwVersionError (P:\Projects\ReactNative\apc-c\node_modules\@babel\helper-plugin-utils\lib\index.js:65:11)
    at Object.assertVersion (P:\Projects\ReactNative\apc-c\node_modules\@babel\helper-plugin-utils\lib\index.js:13:11)
    at _default (P:\Projects\ReactNative\apc-c\node_modules\@babel\preset-env\lib\index.js:154:7)
    at P:\Projects\ReactNative\apc-c\node_modules\@babel\helper-plugin-utils\lib\index.js:19:12
    at P:\Projects\node_modules\babel-core\lib\transformation\file\options\option-manager.js:317:46
    at Array.map (<anonymous>)

I have tried a number of this from installing "7.0.0-bridge.0", etc.

Can someone please help. Have spent hours trying to fix this. Thanks

Arun
  • 3,036
  • 3
  • 35
  • 57
  • Does this answer your question? [Requires Babel "7.0.0-0" but was loaded with "6.26.3"](https://stackoverflow.com/questions/51873516/requires-babel-7-0-0-0-but-was-loaded-with-6-26-3) – Michael Freidgeim Dec 15 '20 at 22:05

3 Answers3

4

Found the problem. I had a .babelrc file that contained a reference to @babel/preset-env and transform-react-jsx. Removed them and the js file compiled just fine.

Arun
  • 3,036
  • 3
  • 35
  • 57
0

I think I can help. Been facing same issue (though not React-native just React) and just got to fix it now, can I see what your package json looks like? Maybe you can update your question with it. Also what script command produces this error?

Vanessa
  • 43
  • 3
  • 12
  • Thanks Vanassa, I have asked a follow up question with all the required details - https://stackoverflow.com/questions/54157519/unable-to-run-a-node-js-file-with-babel-preset-env Can you please check. – Arun Jan 12 '19 at 07:38
0

maybe you could install global babel-cli, you can try the command

npm uninstall -g babel-cli babel-node

you need to install @babel/cli and @babel/node. OR you can uninstall node and remove the npm file in C:\Users\Administrator\AppData\Roaming

I hope I can help you. good luck

Bonifacio2
  • 3,405
  • 6
  • 34
  • 54