graphql-schema-typescript icon indicating copy to clipboard operation
graphql-schema-typescript copied to clipboard

CLI not working on mac

Open abhishiv opened this issue 4 years ago • 8 comments

./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?

abhishiv avatar Mar 18 '21 20:03 abhishiv

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

IngusSkaistkalns avatar Apr 02 '21 13:04 IngusSkaistkalns

@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 avatar Apr 02 '21 13:04 IngusSkaistkalns

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

IngusSkaistkalns avatar Apr 02 '21 14:04 IngusSkaistkalns

I'm also experiencing this issue!

Thanks for reporting @IngusSkaistkalns :)

drewlustro avatar Apr 14 '21 23:04 drewlustro

This needs an automated solution

I get this with 1.3.2 and 1.5.2

tony avatar May 05 '21 19:05 tony

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..."
  }
}

tony avatar May 05 '21 19:05 tony

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!

mocantimoteidavid avatar Oct 07 '21 12:10 mocantimoteidavid

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 👍

adamxklarna avatar Dec 14 '21 11:12 adamxklarna