I am using Babel 6 for es2015 and react which requires babel-preset-es2015
and babel-preset-react
.
I add the presets
property in .babelrc
but it throw me an error:
ERROR in ./src/client/entry.js
Module build failed: ReferenceError: [BABEL] /Users/brick/Dropbox/learncoding/node.js/isomorphic/src/client/entry.js: Unknown option: /Users/brick/Dropbox/learncoding/node.js/isomorphic/.babelrc.presets
at Logger.error (/Users/brick/Dropbox/learncoding/node.js/isomorphic/node_modules/babel-core/lib/transformation/file/logger.js:58:11)
at OptionManager.mergeOptions (/Users/brick/Dropbox/learncoding/node.js/isomorphic/node_modules/babel-core/lib/transformation/file/options/option-manager.js:126:29)
at OptionManager.addConfig (/Users/brick/Dropbox/learncoding/node.js/isomorphic/node_modules/babel-core/lib/transformation/file/options/option-manager.js:107:10)
at OptionManager.findConfigs (/Users/brick/Dropbox/learncoding/node.js/isomorphic/node_modules/babel-core/lib/transformation/file/options/option-manager.js:168:35)
at OptionManager.init (/Users/brick/Dropbox/learncoding/node.js/isomorphic/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229:12)
at File.initOptions (/Users/brick/Dropbox/learncoding/node.js/isomorphic/node_modules/babel-core/lib/transformation/file/index.js:147:75)
at new File (/Users/brick/Dropbox/learncoding/node.js/isomorphic/node_modules/babel-core/lib/transformation/file/index.js:137:22)
at Pipeline.transform (/Users/brick/Dropbox/learncoding/node.js/isomorphic/node_modules/babel-core/lib/transformation/pipeline.js:164:16)
at transpile (/Users/brick/Dropbox/learncoding/node.js/isomorphic/node_modules/babel-loader/index.js:12:22)
at Object.module.exports (/Users/brick/Dropbox/learncoding/node.js/isomorphic/node_modules/babel-loader/index.js:69:12)
@ multi main
My .babelrc
file is:
{
"presets": [
"es2015",
"react"
]
}
I can run babel src -d lib
command, it works. But if I run npm start
to run the babel
via package.json
, the error appears.
I think I can ignore the error because the app runs. But I want to know why this error and not sure what it affects.
My scripts
in package.json
is:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"clean": "rm -rf lib",
"build": "npm run clean && /usr/local/bin/babel src -d lib --experimental",
"server": "nodemon lib/server/server",
"dev-server": "node lib/server/webpack",
"watch-js": "/usr/local/bin/babel src -d lib --experimental -w",
"start": "npm run watch-js & npm run dev-server & npm run server"
},
My entry.js
is
import React from "react";
import Router from "react-router";
import ReactDOM from "react-dom";
import routes from "./routes";
import DataWrapper from './DataWrapper';
import createBrowserHistory from 'history/lib/createBrowserHistory';
let history = createBrowserHistory();
var data = JSON.parse(document.querySelector('#data').innerHTML);
ReactDOM.render(<DataWrapper data={data}><Router history = {history}>{routes}</Router></DataWrapper>, document.querySelector('#app'));