I'm creating projects via command line using:
npx create-react-app xxxxxx
I created a whole batch file to handle the entire thing, to add a couple modules like babel, lodash, and webpack, add some other modules to resolve some "peer" issues, and to move a few files aropund to make it easier to manage files with babel and webpack. This is the batch file contents:
@echo off
IF %1.==. GOTO No1
Goto SetName
:Dowork
cls
echo New folder name: %arg1%
call npx create-react-app %arg1%
cd %arg1%
mkdir dev
mkdir dist
@echo on
::call npm init -y
call npm install node-sass --save-dev
call npm install sass --save-dev
call npm install fibers --save-dev
call npm install react-router-dom --save-dev
::call npm install webpack webpack-cli --save-dev
::call npm install lodash --save-dev
::call npm install @babel/core @babel/cli babel-preset-react-app --save-dev
@echo off
xcopy ..\_run_babel.bat /Q > nul
xcopy ..\_run_webpack.bat /Q > nul
move .\src\* .\dev\ > nul
cd ..\
set arg1=
echo Setup complete
GOTO End1
:SetName
set arg1=%1
GOTO Dowork
:No1
cls
set /p entry=Enter project/folder name:
IF %entry%.==. GOTO NoName
set arg1=%entry%
set entry=
GOTO Dowork
:NoName
cls
ECHO No project/folder name specified
GOTO End1
:End1
The batch file does a create job of creating everything. The folder then gets added as a project within Eclipse ("Eclipse IDE for JavaScript and Web Developers", Version: 2019-12 (4.14.0)). However, right now I'm just trying to get it to process simple work, and I'm having trouble. It doesn't even want to handle the default files created with a new project. I kick off babel with the following:
npx babel-cli --watch dev --out-dir src --presets react-app/prod
With that, I get errors like the following for every file it tries to process:
ReferenceError: [BABEL] dev\App.js: Unknown option: %project_folder%\node_modules\babel-preset-react-app\prod.js.overrides. Check out http://babeljs.io/docs/usage/options/ for more information about options
.
A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:
Invalid:
`{ presets: [{option: value}] }`
Valid:
`{ presets: [['presetName', {option: value}]] }`
For more detailed information on preset configuration, please see https://babeljs.io/docs/en/plugins#pluginpresets-options. (While processing preset: "%project_folder%\\node_modules\\babel-preset-react-
app\\prod.js")
at Logger.error (%AppData%\Roaming\npm-cache\_npx\19028\node_modules\babel-cli\node_modules\babel-core\lib\transformation\file\logger.js:41:11)
at OptionManager.mergeOptions (%AppData%\Roaming\npm-cache\_npx\19028\node_modules\babel-cli\node_modules\babel-core\lib\transformation\file\options\option-manager.js:226:20)
at %AppData%\Roaming\npm-cache\_npx\19028\node_modules\babel-cli\node_modules\babel-core\lib\transformation\file\options\option-manager.js:265:14
at %AppData%\Roaming\npm-cache\_npx\19028\node_modules\babel-cli\node_modules\babel-core\lib\transformation\file\options\option-manager.js:323:22
at Array.map (<anonymous>)
at OptionManager.resolvePresets (%AppData%\Roaming\npm-cache\_npx\19028\node_modules\babel-cli\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
at OptionManager.mergePresets (%AppData%\Roaming\npm-cache\_npx\19028\node_modules\babel-cli\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
at OptionManager.mergeOptions (%AppData%\Roaming\npm-cache\_npx\19028\node_modules\babel-cli\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
at OptionManager.init (%AppData%\Roaming\npm-cache\_npx\19028\node_modules\babel-cli\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
at File.initOptions (%AppData%\Roaming\npm-cache\_npx\19028\node_modules\babel-cli\node_modules\babel-core\lib\transformation\file\index.js:212:65)
I really don;t understand this well enough to know why this is happening, or how to fix it? Is there something I'm doing wrong with the project initialization? Something different I should be doing with running babel? It's very confusing because I had created a couple projects before and had no issues, but I had to put this aside for a while to handle other things, and for the life of me I can't figure why I can't get this to work now.
-- EDIT --
I think I've identified the source of the issue. It seems to be the react preset: babel-preset-react-app. Supposedly it's installed with the create-react-app process. Just for kicks, I've also tried installing the preset separately. The only time I don't get the error messages is if I run babel-cli without defining the react-app preset. Can I remove the preset and then install on older version?