Graphql-code-generator: Unable to run gql-gen from command line after installing

Created on 25 Jan 2019  路  4Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug
I installed npm install graphql-code-generator and ran gql-gen but my zsh just returns 'No command gql-gen found'.

Environment:

  • OS: Mac
  • Node: v11.7.0

Additional context
Ran this on a coworker's laptop, same issue

Most helpful comment

@FrankSandqvist @mhuconcern
It's a general issue with npm and yarn executables.
You should either add it as script to your package.json and then run it using yarn SCRIPT or npm run SCRIPT.
If you wish to use it as gql-gen directly, you should install it as global module (npm install -g or yarn global add).

Also, if you are using Yarn, you should be able to run yarn gql-gen.

All 4 comments

Having issues with this too. How did you fix it?

Trying globally and locally, nothing seems to work for me.

I finally got it to run by adding it as a script and then running the script. It didnt work for me from cli

Thanks, I'll try that.

@FrankSandqvist @mhuconcern
It's a general issue with npm and yarn executables.
You should either add it as script to your package.json and then run it using yarn SCRIPT or npm run SCRIPT.
If you wish to use it as gql-gen directly, you should install it as global module (npm install -g or yarn global add).

Also, if you are using Yarn, you should be able to run yarn gql-gen.

Was this page helpful?
0 / 5 - 0 ratings