Graphql-code-generator: v1.9.0 not running cli

Created on 27 Nov 2019  ·  14Comments  ·  Source: dotansimha/graphql-code-generator

I think you forgot a dependency: json-to-pretty-yaml
(Running npm-ls json-to-pretty-yaml returns empry)

Error: Cannot find module 'json-to-pretty-yaml'.
Require stack:
- C:\Dev\smartvideo-hub\smartvideo-hub\node_modules\@graphql-codegen\cli\bin.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\Dev\smartvideo-hub\smartvideo-hub\node_modules\@graphql-codegen\cli\bin.js:1001:14)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10
bug core waiting-for-release

Most helpful comment

Same error but for a different dependency :

$ graphql-codegen --watch
[1] Error: Cannot find module 'listr-update-renderer'
[1] Require stack:
[1] - /home/jgoux/Projects/oss/typezafe/node_modules/@graphql-codegen/cli/bin.js
[1]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:954:17)
[1]     at Function.Module._load (internal/modules/cjs/loader.js:847:27)
[1]     at Module.require (internal/modules/cjs/loader.js:1016:19)
[1]     at require (internal/modules/cjs/helpers.js:69:18)
[1]     at Object.<anonymous> (/home/jgoux/Projects/oss/typezafe/node_modules/@graphql-codegen/cli/bin.js:159:24)
[1]     at Module._compile (internal/modules/cjs/loader.js:1121:30)
[1]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
[1]     at Module.load (internal/modules/cjs/loader.js:976:32)
[1]     at Function.Module._load (internal/modules/cjs/loader.js:884:14)
[1]     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:67:12)
error Command failed with exit code 1.

All 14 comments

Same error but for a different dependency :

$ graphql-codegen --watch
[1] Error: Cannot find module 'listr-update-renderer'
[1] Require stack:
[1] - /home/jgoux/Projects/oss/typezafe/node_modules/@graphql-codegen/cli/bin.js
[1]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:954:17)
[1]     at Function.Module._load (internal/modules/cjs/loader.js:847:27)
[1]     at Module.require (internal/modules/cjs/loader.js:1016:19)
[1]     at require (internal/modules/cjs/helpers.js:69:18)
[1]     at Object.<anonymous> (/home/jgoux/Projects/oss/typezafe/node_modules/@graphql-codegen/cli/bin.js:159:24)
[1]     at Module._compile (internal/modules/cjs/loader.js:1121:30)
[1]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
[1]     at Module.load (internal/modules/cjs/loader.js:976:32)
[1]     at Function.Module._load (internal/modules/cjs/loader.js:884:14)
[1]     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:67:12)
error Command failed with exit code 1.

I tried regenerating yarn.lock but it still does not work.

❯ yarn gql:gen
yarn run v1.19.1
$ graphql-codegen --config codegen.yml
Error: Cannot find module 'listr-update-renderer'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/Users/rot1024/src/github.com/darwin-education/reearth-web/node_modules/@graphql-codegen/cli/bin.js:159:24)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Workaround:

yarn add --dev json-to-pretty-yaml listr listr-update-renderer

The version that was published in the npm repository differs from the tagged commit for 1.9.0 (https://github.com/dotansimha/graphql-code-generator/releases/tag/v1.9.0)

Inspecting the package.json of what gets installed, it doesn't have the listr dependencies:

  "dependencies": {
    "@graphql-codegen/core": "1.8.3",
    "@graphql-codegen/plugin-helpers": "1.8.3",
    "@graphql-toolkit/code-file-loader": "0.7.2",
    "@graphql-toolkit/core": "0.7.2",
    "@graphql-toolkit/git-loader": "0.7.2",
    "@graphql-toolkit/github-loader": "0.7.2",
    "@graphql-toolkit/graphql-file-loader": "0.7.2",
    "@graphql-toolkit/json-file-loader": "0.7.2",
    "@graphql-toolkit/url-loader": "0.7.2",
    "chalk": "3.0.0",
    "commander": "4.0.1",
    "common-tags": "1.8.0",
    "cosmiconfig": "6.0.0",
    "debounce": "1.2.0",
    "detect-indent": "6.0.0",
    "graphql-config": "3.0.0-alpha.14",
    "indent-string": "4.0.0",
    "inquirer": "7.0.0",
    "is-glob": "4.0.1",
    "log-symbols": "3.0.0",
    "log-update": "3.3.0",
    "mkdirp": "0.5.1",
    "ts-log": "2.1.4"
  }

Please republish this version with updated package.json.

You are right, it's related to a change we did in our build system.
@ardatan and @kamilkisiela are taking a look :)

Same error but for a different dependency :

$ graphql-codegen --watch
[1] Error: Cannot find module 'listr-update-renderer'
[1] Require stack:
[1] - /home/jgoux/Projects/oss/typezafe/node_modules/@graphql-codegen/cli/bin.js
[1]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:954:17)
[1]     at Function.Module._load (internal/modules/cjs/loader.js:847:27)
[1]     at Module.require (internal/modules/cjs/loader.js:1016:19)
[1]     at require (internal/modules/cjs/helpers.js:69:18)
[1]     at Object.<anonymous> (/home/jgoux/Projects/oss/typezafe/node_modules/@graphql-codegen/cli/bin.js:159:24)
[1]     at Module._compile (internal/modules/cjs/loader.js:1121:30)
[1]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
[1]     at Module.load (internal/modules/cjs/loader.js:976:32)
[1]     at Function.Module._load (internal/modules/cjs/loader.js:884:14)
[1]     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:67:12)
error Command failed with exit code 1.

I am also getting this error.

+1

People, as @rot1024 mentioned, try this as a workaround while they are investigating—works for me:

yarn add --dev json-to-pretty-yaml listr listr-update-renderer

Once they release a patch, just do

yarn remove json-to-pretty-yaml listr listr-update-renderer && yarn

Could you try with the following canary version?
1.9.1-alpha-ca2b8a1c.2

Could you try with the following canary version?
1.9.1-alpha-ca2b8a1c.2

It seems to work without flaws. Thank you for the quick fix!

While running the canary, I get the following error.

Unable to load preset matching 'near-operation-file'.
                  Reason:
                    Cannot find module 'relay-compiler/lib/transforms/RelayApplyFragmentArgumentTransform'
    Require stack:
    - [my folder path]/node_modules/@graphql-codegen/near-operation-file-preset/node_modules/@graphql-codegen/visitor-plugin-common/dist/commonjs/optimize-operations.js
    - [my folder path]/node_modules/@graphql-codegen/near-operation-file-preset/node_modules/@graphql-codegen/visitor-plugin-common/dist/commonjs/index.js
    - [my folder path]/node_modules/@graphql-codegen/near-operation-file-preset/index.cjs.js
    - [my folder path]/node_modules/@graphql-codegen/cli/bin.js
    Error: Unable to load preset matching near-operation-file
        at getPresetByName ([my folder path]/node_modules/@graphql-codegen/cli/bin.js:265:23)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)
    Error: Unable to load preset matching near-operation-file
        at getPresetByName ([my folder path]/node_modules/@graphql-codegen/cli/bin.js:265:23)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)

I upgraded all my @graphql-codegen/* packages to the canary build

Update: switching @graphql-codegen/near-operation-file-preset back to 1.9.0 fixed it.

@roborich How about 1.9.1-alpha-895dc50c.7+895dc50c?

any eta for stable release 1.9.1?

@ardatan 1.9.1-alpha-895dc50c.7+895dc50c 👌Thanks! Bing, NY 👊 represent

Fixed in 1.9.1 :)
Thanks @ardatan !

Was this page helpful?
0 / 5 - 0 ratings