【问题标题】:How to Compile React-Relay如何编译 React-Relay
【发布时间】:2021-11-29 11:28:43
【问题描述】:

我正在尝试关注the official Relay documentation here

安装 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:\xampp\htdocs\my-react\test
> npm run relay && react-scripts start


> test@0.1.0 relay D:\xampp\htdocs\my-react\test
> npm run relay-compiler --schema schema.graphql --src ./src/ --watchman false $@

npm ERR! missing script: relay-compiler

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

【问题讨论】:

    标签: reactjs npm relayjs relay react-relay


    【解决方案1】:

    显然,我必须删除 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 $@"
        ...
      },
      ...
    }
    

    【讨论】:

      猜你喜欢
      • 2018-02-12
      • 2016-08-09
      • 2018-05-08
      • 2016-07-25
      • 1970-01-01
      • 2016-11-19
      • 2016-02-01
      • 2019-06-18
      • 2021-04-28
      相关资源
      最近更新 更多