相关疑难解决方法(0)

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()
Run Code Online (Sandbox Code Playgroud)

And when I run it I get the error "SyntaxError: Cannot use import statement outside a module". First I tried doing things to convince TPTB* that this was a module (with no success). So I changed the "import" to a "require" and this worked.

But now …

javascript node.js babeljs apollo-server

10
推荐指数
15
解决办法
1万
查看次数

标签 统计

apollo-server ×1

babeljs ×1

javascript ×1

node.js ×1