Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected token import (from flow-runtime) #183

Open
4 tasks done
OKNoah opened this issue Dec 31, 2017 · 2 comments
Open
4 tasks done

SyntaxError: Unexpected token import (from flow-runtime) #183

OKNoah opened this issue Dec 31, 2017 · 2 comments
Labels

Comments

@OKNoah
Copy link

OKNoah commented Dec 31, 2017

This is a:

  • Bug Report
  • Question

Which concerns:

  • flow-runtime
  • babel-plugin-flow-runtime

What is the current behaviour?

The complete configuration is here: https://github.com/OKNoah/flow-runtime-test

package.json

{
  "presets": [
    "stage-2",
    "react"
  ],
  "plugins": [["flow-runtime"], "transform-decorators-legacy"]
}

index.js

// @flow-runtime

type User = {
  name: string
};

console.log('henlo')
[nodemon] starting `node -r babel-register index.js`
/Users/noah/Projects/flow-runtime-test/index.js:1
(function (exports, require, module, __filename, __dirname) { import t from 'flow-runtime';
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:599:28)
    at loader (/Users/noah/Projects/flow-runtime-test/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/noah/Projects/flow-runtime-test/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
[nodemon] app crashed - waiting for file changes before starting...

What is the expected behaviour?

Should compile without errors and console log.


Which package versions are you using?

"babel": "^6.23.0",
"babel-plugin-flow-runtime": "^0.15.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.26.0",
"flow-runtime": "^0.16.0"
@OKNoah
Copy link
Author

OKNoah commented Dec 31, 2017

The fix is to simply add babel-preset-env.

{
  "presets": [
    "env",
    "stage-2",
    "react"
  ],
  "plugins": [["flow-runtime"], "transform-decorators-legacy"]
}

and

npm install --dev babel-preset-env

@skeggse
Copy link
Contributor

skeggse commented Nov 19, 2019

Related to #207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants