question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

--config-file option does not work with @babel/cli.

See original GitHub issue

Bug 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:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
nicolo-ribaudocommented, Nov 5, 2019

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)

4reactions
loganfsmythcommented, Oct 23, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found