dangcuuson / graphql-schema-typescript

Generate TypeScript from GraphQL's schema type definitions
191 stars 36 forks source link

CLI not working on mac #56

Open abhishiv opened 3 years ago

abhishiv commented 3 years ago
./node_modules/.bin/graphql-schema-typescript generate-ts --help
env: node\r: No such file or directory

node is installed ofc. Issue with line endings?

IngusSkaistkalns commented 3 years ago

+1. I updated from [js] Update graphql-schema-typescript: 1.3.2 → 1.5.2

IngusSkaistkalns commented 3 years ago

@abhishiv as a hotfix i just converted file node_modules/.bin/graphql-schema-typescript from CRLF to LF. EDIT: Whoops, did not notice that thats a symlink to actual library -> graphql-schema-typescript/lib/cli.js

IngusSkaistkalns commented 3 years ago

I installed package and it seems that CRLF issue is present in npm package, but not in current git source (or is it because of git handling this somehow automagically???) :/

find /Users/skaising/.nvm/versions/node/v14.15.4/lib/node_modules/graphql-schema-typescript/lib/cli.js -exec file "{}" ";"
/Users/skaising/.nvm/versions/node/v14.15.4/lib/node_modules/graphql-schema-typescript/lib/cli.js: Node.js script text executable, ASCII text, with CRLF, LF line terminators

and git source:

skaising@Ingus-Skaistkalns ~ % find /Users/skaising/code/graphql-schema-typescript/src/cli.ts -exec file "{}" ";"            
/Users/skaising/code/graphql-schema-typescript/src/cli.ts: Node.js script text executable, ASCII text
drewlustro commented 3 years ago

I'm also experiencing this issue!

Thanks for reporting @IngusSkaistkalns :)

tony commented 3 years ago

This needs an automated solution

I get this with 1.3.2 and 1.5.2

tony commented 3 years ago

Invoke it like this in CLI and scripts: node node_modules/.bin/graphql-schema-typescript

Before:

{
  "scripts": {
    "gen:schema": "graphql-schema-typescript ...args..."
  }
}

After

{
  "scripts": {
    "gen:schema": "node node_modules/.bin/graphql-schema-typescript ...args..."
  }
}
mocantimoteidavid commented 3 years ago

I am also experiencing the same exact issue. Upgraded from 1.3.2 to 1.5.2.

Thank you a lot @tony for the temporary workaround!

adamxklarna commented 2 years ago

I opened a PR to fix line endings on commit by default. That should take care of the first part of this issue. The second one would be taken care of if/when the npm package is updated/rebuilt with correct line endings 🙏

In the meantime, the absolute easiest way to bypass this issue if you run into it, is to run the following command in the project folder where the package was installed (it normalizes the line endings of all the package files recursively): $ npx crlf --set=LF ./node_modules/graphql-schema-typescript/**/*

Credit goes to this guy, who's blog post I found when troubleshooting the issue 👍