我通过添加插件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,但同样的问题也出现了。
谢谢 !
您已经安装了gatsby-plugin-flow
,但您还需要将其作为插件添加到gatsby-config.js
文件中。
盖茨比-config.js
module.exports = {
plugins: ['gatsby-plugin-flow'],
}