Graphql-code-generator: graphql-codegen is not recognized as a command on Windows 10

Created on 12 Sep 2019  Â·  3Comments  Â·  Source: dotansimha/graphql-code-generator

Describe the bug
When I try to execute graphql-codegen, windows 10 says it doesn't know what it is. I'm willing to believe it's something I'm doing (or not doing), but I think I followed the instructions for installation.

To Reproduce
I go to an empty directory, type 'yarn init' and initialize a project. Then I type 'yarn -D graphql @graphql-codegen/cli'. Both commands appear to terminate normally and install a bunch of stuff.

Here's the resulting package.json

{
"name": "search-gql",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@graphql-codegen/cli": "^1.7.0",
"graphql": "^14.5.4"
}
}

Then I type: 'graphql-codegen init" and Windows 10 says ''graphql-codegen' is not recognized as an internal or external command, operable program or batch file.'

Can someone tell me what I missed?

  1. My GraphQL schema:
# Put your schema here
  1. My GraphQL operations:
# Put your operations here
  1. My codegen.yml config file:
# Put your YML here

Expected behavior

Environment:

  • OS:
  • @graphql-codegen/...:
  • NodeJS:

Additional context

Most helpful comment

@Smitty010
You installed the CLI as local dev of your project, it means you should run it from yarn as yarn graphql-codegen, or, with npx.
The best solution is to create a NPM script that runs graphql-codegen, and then to use that script.
If that doesn't work, please share a repo with a reproduction.

All 3 comments

Could you try ‘yarn graphql-codegen init’

That does seem to work.

@Smitty010
You installed the CLI as local dev of your project, it means you should run it from yarn as yarn graphql-codegen, or, with npx.
The best solution is to create a NPM script that runs graphql-codegen, and then to use that script.
If that doesn't work, please share a repo with a reproduction.

Was this page helpful?
0 / 5 - 0 ratings