--config-file option does not work with @babel/cli.
See original GitHub issueBug Report
Current Behavior
17:33:10 [jwalton@morgana ~/benbria/node-promise-tools] (master) $ cat babelModules.js
module.exports = {
"presets": [
["@babel/env", { "targets": "> 0.25%, not dead", "modules": false }]
]
}
17:33:09 [jwalton@morgana ~/benbria/node-promise-tools] (master) $ ./node_modules/.bin/babel --config-file babelModules.js -d dist/modules src
{ Error: Cannot find module 'babelModules.js' from '/Users/jwalton/benbria/node-promise-tools'
at Function.module.exports [as sync] (/Users/jwalton/benbria/node-promise-tools/node_modules/@babel/core/node_modules/resolve/lib/sync.js:43:15)
at loadConfig (/Users/jwalton/benbria/node-promise-tools/node_modules/@babel/core/lib/config/files/configuration.js:158:39)
at buildRootChain (/Users/jwalton/benbria/node-promise-tools/node_modules/@babel/core/lib/config/config-chain.js:76:40)
at loadPrivatePartialConfig (/Users/jwalton/benbria/node-promise-tools/node_modules/@babel/core/lib/config/partial.js:85:55)
at loadFullConfig (/Users/jwalton/benbria/node-promise-tools/node_modules/@babel/core/lib/config/full.js:43:39)
at process.nextTick (/Users/jwalton/benbria/node-promise-tools/node_modules/@babel/core/lib/transform-file.js:48:33)
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickCallback (internal/process/next_tick.js:181:9)
at Function.Module.runMain (module.js:696:11)
at startup (bootstrap_node.js:204:16) code: 'MODULE_NOT_FOUND' }
Expected behavior
Babel should load the config file specified and use it.
Environment
- Babel version(s): 7.1.2
- Node/npm version: Node 8.12.0/npm 6.4.1
- OS: OSX 10.13.6
- Monorepo No
- How you are using Babel: CLI
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Babel-CLI set config value correctly - Stack Overflow
You can use ./node_modules/.bin/babel in place of babel . Worked for me this week. Check point 3 in the overview from babel-cli ......
Read more >Babel CLI
Babel comes with a built-in CLI which can be used to compile files from the command line.
Read more >What is @babel/preset-env and why do I need it? - Jakob Lind
This is part 2 of my post about implementing ES6 with Babel and webpack. In the first part, you learned the basics of...
Read more >Options · Babel 中文网
Defaults to searching for a default babel.config.json file, but can be passed the path of any JS or JSON5 config file. NOTE: This...
Read more >@babel/cli | Yarn - Package Manager
... fix: report missing plugins on type exports (@JLHwung); #11388 fix: do not push new token context when function is following dot/questionDot (@JLHwung)....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Reddit’s folks are correct. babel-cli is Babel 6 and @babel/cli is Babel 7 (babel.config.js has been introduced in v7.0.0)
I don’t know if this was the right call design-wise, but this all behaves like
require("babelModules.js")
, which means that for it to find the config file, you need a./
before the filename.