I'm getting an error saying "unexpected token export" when trying to compile some es6 code using "babel-cli" with the presets "es2015" and "stage-2". I'm trying to export a function from the "test.js" file and import it in the "index.js" file but for some reason it doesn't accept "export" in "test.js".
Each module is installed locally, so I run it from the package.json "scripts" using "build: babel server/index.js -o server/index.babel.js".
My ".babelrc" file consists of:
{
"presets": ["es2015", "stage-2"]
}
test.js:
const test = (msg) => {
console.log(msg)
};
export default test;
index.js:
index.js:
import test from './test'
test("Hello")
Any help is much appreciated.
test.js
? – Ja9ad335hindex.js
in "scripts build:". you also need to do the same fortest.js
– Ja9ad335h