I'm trying to run a simple node.js file which needs the @babel/preset-env preset. The moment I run the js file, I get a message saying
Requires Babel “7.0.0-0” but was loaded with “6.26.3”
To replicate the issue, please try the following in a new folder: 1. Run the following commands
npm init
npm install @babel/register
npm install @babel/core@^7.2.2
npm install @babel/preset-env
{ "presets": ["@babel/preset-env"], "plugins": [] }
import React from "react"; class CommentBox extends React.Component {}
require('babel-register')({presets: ['env', 'react']}); let Emp = require('./emp.jsx');
Now run the parse.js file by running
node parse.js
You should see the error mentioned above. I have been trying to fix with for a long time now. Please help.
Many Thanks
Found the problem. The .babelrc file that contained a reference to @babel/preset-env. Removed it and the js file compiled just fine.