如何编译React-Relay



我在这里尝试遵循官方中继文档。

安装React-Relay后:

npm install --save relay-runtime react-relay
npm install --save-dev relay-compiler graphql babel-plugin-relay

…配置package.json:

{
...
"scripts": {
...
"start": "npm run relay && react-scripts start",
"build": "npm run relay && react-scripts build",
"relay": "npm run relay-compiler --schema schema.graphql --src ./src/ --watchman false $@"
...
},
...
}

当我跑:

npm start

我得到了以下错误:

> test@0.1.0 start D:xampphtdocsmy-reacttest
> npm run relay && react-scripts start

> test@0.1.0 relay D:xampphtdocsmy-reacttest
> npm run relay-compiler --schema schema.graphql --src ./src/ --watchman false $@
npm ERR! missing script: relay-compiler

如何正确运行中继编译器?

显然,我必须删除package.json最后一行中的'npm run':

{
...
"scripts": {
...
"start": "npm run relay && react-scripts start",
"build": "npm run relay && react-scripts build",
"relay": "relay-compiler --schema schema.graphql --src ./src/ --watchman false $@"
...
},
...
}

最新更新