1

I am trying to follow the official Relay documentation here.

After installing React-Relay:

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

... and configuring 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 $@"
    ...
  },
  ...
}

when I ran:

npm start

I got the following error:

> 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

How can I correctly run relay-compiler?

Chong Lip Phang
  • 8,755
  • 5
  • 65
  • 100

1 Answers1

1

Apparently, I must remove 'npm run' in the last line of package.json:

{
  ...
  "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 $@"
    ...
  },
  ...
}
Chong Lip Phang
  • 8,755
  • 5
  • 65
  • 100