【发布时间】:2019-08-06 10:14:38
【问题描述】:
我通过添加插件 gatsby-plugin-flow 在我的 Gatsby 项目中安装了 Flow。
它在项目根目录中创建了一个 .flowconfig 文件,并在 package.json 中创建了一个 "gatsby-plugin-flow": "^1.0.4" 依赖项。
当我运行 gatsby develop 时,出现错误:
ERROR in ./src/components/layout.js
Module build failed (from ./node_modules/gatsby/dist/utils/babel-loader.js):
SyntaxError: /Users/iqc/project/src/components/layout.js: Unexpected token, expected "," (10:29)
8 | import "./layout.css"
9 |
> 10 | const Layout = ({ children } : Object) => (
| ^
11 | <StaticQuery
12 | query={graphql`
Babel 似乎无法编译项目。 也许盖茨比中的 ES6 有问题?
我也尝试使用官方文档(无插件)安装 Flow,但出现同样的问题。
谢谢!
【问题讨论】:
标签: reactjs babeljs flowtype gatsby