Related questions
Using Node.js require vs. ES6 import/export
In a project I'm collaborating on, we have two choices on which module system we can use:
Importing modules using require, and exporting using module.exports and exports.foo.
Importing modules using ES6 import, and exporting using ES6 export
Are …
Babel 6 regeneratorRuntime is not defined
I'm trying to use async, await from scratch on Babel 6, but I'm getting regeneratorRuntime is not defined.
.babelrc file
{
"presets": [ "es2015", "stage-0" ]
}
package.json file
"devDependencies": {
"babel-core": "^6.0.20",
"babel-preset-es2015": "^6.0.15",
"babel-preset-stage-0": "^6.0.15"
}
.js file
"use strict";
async function foo() {
await bar();
}
function bar() { }
…
SyntaxError: Cannot use import statement outside a module
I've got an ApolloServer project that's giving me trouble, so I thought I might update it and ran into issues when using the latest Babel. My "index.js" is:
require('dotenv').config()
import {startServer} from './server'
startServer()
And when …