Skip to content

Unexpected token import for nodejs on GAE Flex #478

Description

@alanma

I deployed a nodejs app on appengine flexible today. But the deployed server won't start with the following error in the logs. I'm confused why my import statement is being marked as errors. Please help! Thanks in advance.

A  /app/src/server/index.js:2
 
A  import gqlServer from './myServer';
 
A  SyntaxError: Unexpected token import
    at createScript (vm.js:53:10)
    at Object.runInThisContext (vm.js:95:10)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:423:7)
    at startup (bootstrap_node.js:147:9)
 
  undefined

Activity

  1. jmdobry commented on Sep 19, 2017

    @jmdobry
    Member

    The import keyword is only supported in the newest Node v8.5.0 I believe, and even then, behind a flag. You'll need to set your engines field in package.json to >=8.5.0 and your start script to node --experimental-modules src/server/index.js. And, I believe your index.js actually needs to be index.mjs. See http://2ality.com/2017/09/native-esm-node.html

  2. JustinBeckwith commented on May 4, 2018

    @JustinBeckwith
    Contributor

    Greetings! This issue has been hanging out for a while. If you're still running into issues... please do let us know! We're going to close this one out for now.

  3. added a commit that references this issue on Nov 16, 2022
  4. added a commit that references this issue on Nov 16, 2022
  5. added a commit that references this issue on Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🚨This issue needs some love.triage meI really want to be triaged.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions