"SourceError Unknown source plugin" when I try to convert js files to a directory using babel cli

I am a little new to Babylon. I was successful when I tried to convert some .jsx files to a directory using this command:

babel --plugins transform-react-jsx test.js

But when I tried to convert the list of jsx files to a directory, it failed. Here is the command message and errors:

babel --plugins transform-react-jsx ../public/js/bundle/temp_realtime/ -d ../public/js/bundle/realtime

ReferenceError: Unknown plugin "transform-react-jsx" specified in "base" at 0, attempted to resolve relative to "../public/js/bundle/temp_realtime"
    at /usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:193:17
    at Array.map (native)
    at Function.normalisePlugins (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:173:20)
    at OptionManager.mergeOptions (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:271:36)
    at OptionManager.init (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:416:10)
    at File.initOptions (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/index.js:191:75)
    at new File (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/index.js:122:22)
    at Pipeline.transform (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/pipeline.js:42:16)
    at transform (/usr/local/lib/node_modules/babel-cli/lib/babel/util.js:53:22)
    at Object.compile (/usr/local/lib/node_modules/babel-cli/lib/babel/util.js:62:12)

I have no idea why it happened. The babel-plugin-transform-react-jsx plugin was installed using the command:

npm install babel-plugin-transform-react-jsx 
+4
source share
1 answer

This happened to me because I accidentally used:

{
  "plugins": ["es2015", "react"]
}

when I meant:

{
  "presets": ["es2015", "react"]
}
+8
source

Source: https://habr.com/ru/post/1623186/


All Articles