babel-loader: Unknown Option
webpack.js:
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel'
}
]
}
.babelrc:
{
"blacklist": [
"useStrict"
],
"plugins": [
"transform-es2015-modules-commonjs"
],
"presets": [
"react",
"es2015",
"stage-0",
"stage-1",
"stage-2",
"stage-3"
]
}
Command:
./node_modules/.bin/webpack --config webpack.js
Expected result: successful build
Actual result:
Unknown option: .babelrc.blacklist
at Logger.error (node_modules/babel-core/lib/transformation/file/logger.js:43:11)
at OptionManager.mergeOptions (node_modules/babel-core/lib/transformation/file/options/option-manager.js:245:18)
at OptionManager.addConfig (node_modules/babel-core/lib/transformation/file/options/option-manager.js:206:10)
at OptionManager.findConfigs (node_modules/babel-core/lib/transformation/file/options/option-manager.js:347:16)
at OptionManager.init (node_modules/babel-core/lib/transformation/file/options/option-manager.js:392:12)
at File.initOptions (node_modules/babel-core/lib/transformation/file/index.js:191:75)
at new File (node_modules/babel-core/lib/transformation/file/index.js:122:22)
at Pipeline.transform (node_modules/babel-core/lib/transformation/pipeline.js:42:16)
at transpile (node_modules/babel-loader/index.js:12:22)
at Object.module.exports (node_modules/babel-loader/index.js:69:12)
@ multi export
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 73 (7 by maintainers)
Commits related to this issue
- Explicitly use Babel object rest spread transform - https://github.com/babel/babel-loader/issues/132 — committed to minifast/lektor by deleted user 8 years ago
- Add Jasmine - Explicitly use Babel object rest spread transform: https://github.com/babel/babel-loader/issues/132 - Include babel-register, transform-decorators-legacy, transform-runtime, preset-stag... — committed to minifast/lektor by deleted user 8 years ago
Hi, I had a very similar issue where my babel preset options were unknown. I’m pretty new to all this, but
npm install babel-preset-es2015
andnpm install babel-preset-react
solved my problem. I forgot to install the dependencies beforehand, and after installing them things worked out.I solved it.💡
The issue for me was that
npm install babel-loader --save-dev
was installing an incorrect version of babel-loader (^5.4.0
).I edited my package.json manually, setting the version to
^6.1.0
, removed thenode_modules
directory, and then rannpm install
, which fixed the issue.I think this issue should be closed since there’s just too many comments for people to know what is going on. I will post a summary of the potential solutions.
If you are getting unknown option on babel 6 you could of spelled the option wrong or are using a .babelrc with options for babel 5 that was removed in babel 6 (stage, whitelist, blacklist, etc).
For example you might be using
preset
when the option is actuallypresets
.Or it could be because you have a global and a local version of babel and one of those is still on Babel 5, or that you are loading the files for another project that is also still on babel 5.
Or make sure you are on the latest versions of the packages you are using (babel-loader, babel, etc) and that the correct packages are installed rather than just specifying the correct config.
I had this problem as well (
Unknown option: direct.presets
). It seems to have stemmed from a mismatch in Babel 6 installed globally and Babel 5 installed locally. Updating the local copy solved it.FYI, I hit this error because I had
babel-loader
installed but notbabel-core
(it’s not automatically installed because it’s a peer dependency)“exclude” solves the problem.
loaders: [ { test: /.js$/, loader: ‘babel-loader’, include: [ path.resolve(__dirname, ‘test’), path.resolve(__dirname, ‘src’) ], exclude: /node_modules/ },
remove all the .babelrc files from the node_modules. rm $( find node_modules -name .babelrc)
Getting a similar issue when running babel with both direct presets, and .babelrc.
.babelrc
I was having the same issue:
ReferenceError: [BABEL] repl: Unknown option: presets
which I had defined in.babelrc
. Only thing that helped me was to install babel-cli. After that everything worked fine.For me, this problem stemmed from referencing
babel-runtime
in the old way, like so:loader: 'babel-loader?optional[]=runtime'
instead of the new way.I have solved my problems.My error is Module build failed: ReferenceError: [BABEL] D:\coder\node.js\webpack\app\index.js: Unknown option: base.preset. Check out http://babeljs.io/docs/usage/options/ for more info.
it’s a really fuck and silly error.I forget “s” behind “preset”,and it should be “presets”
By upgrading babel-loader to 6.2.4 (and babel-core to 6.8.0), I don’t seems to have this problem anymore.
I have an instance where a module in
node_modules
uses babel, but doesn’t have a.babelrc
file. Similar errors are occurring for me as well.I’ve installed
babel-preset-es2015
&babel-preset-react
in my project but still encountered this problem. But removingnode_modules
&.babelrc
at $HOME path solved this.I was having this issue. I needed to remove
stage-0
from the configuration of my gulpfile.js in my browserify task.I am getting the same problem.
.babelrc
loads in simplyes2015
.So I used updtr to bump the dependencies to the latest versions and it seems to now work.
I love Javascript. 😦
Quick experiment with no promise of success:
Replace:
with