Urigo / graphql-cli

📟 Command line tool for common GraphQL development workflows

Home Page:https://graphql-cli.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: Cannot find module 'graphql-request'

elliottsj opened this issue · comments

Describe the bug

(This issue is for the graphcool-yml package, but making it here because it appears the source of graphcool-yml no longer exists)

I'm using graphql-cli, installed via pnpm, and this error occurs when running graphql-cli:

Error: Cannot find module 'graphql-request'

To Reproduce

$ npm install -g pnpm
$ pnpm install -g graphql-cli
$ graphql
internal/modules/cjs/loader.js:582
    throw err;
    ^

Error: Cannot find module 'graphql-request'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/spencerelliott/.nvm/versions/node/v10.12.0/pnpm-global/1/node_modules/.registry.npmjs.org/graphcool-yml/0.4.15/node_modules/graphcool-yml/dist/Cluster.js:42:25)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)

Full stack trace:

$ env NODE_OPTIONS="--stack-trace-limit=1000" graphql
Stack trace
internal/modules/cjs/loader.js:582
    throw err;
    ^

Error: Cannot find module 'graphql-request'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/spencerelliott/.nvm/versions/node/v10.12.0/pnpm-global/1/node_modules/.registry.npmjs.org/graphcool-yml/0.4.15/node_modules/graphcool-yml/dist/Cluster.js:42:25)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/spencerelliott/.nvm/versions/node/v10.12.0/pnpm-global/1/node_modules/.registry.npmjs.org/graphcool-yml/0.4.15/node_modules/graphcool-yml/dist/index.js:3:17)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/spencerelliott/.nvm/versions/node/v10.12.0/pnpm-global/1/node_modules/.registry.npmjs.org/graphql-config-extension-graphcool/1.0.8/graphql@0.13.2/node_modules/graphql-config-extension-graphcool/dist/index.js:46:23)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/spencerelliott/.nvm/versions/node/v10.12.0/pnpm-global/1/node_modules/.registry.npmjs.org/graphql-cli/2.16.7/node_modules/graphql-cli/dist/index.js:49:44)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/spencerelliott/.nvm/versions/node/v10.12.0/pnpm-global/1/node_modules/.registry.npmjs.org/graphql-cli/2.16.7/node_modules/graphql-cli/dist/bin.js:4:15)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

Expected behavior
graphql-cli produces normal output with no module loading error.

Versions (please complete the following information):

  • OS: macOS Mojave
  • graphql-cli: 2.16.7

Suggested fix
Add 'graphql-request' as a dependency of 'graphcool-yml'. Currently, graphcool-yml does not declare graphql-request as a dependency: https://unpkg.com/graphcool-yml@0.4.15/package.json

My current workaround is to declare 'graphql-request' as a dependency of my application.

This led me to find out that the same issue occurs for the 'tmp' package:

$ ./node_modules/.bin/graphql                                                                                                                                                                               (905ms)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/spencerelliott/Dev/elliottsj/myrepo/common/temp/node_modules/.registry.npmjs.org/graphql-cli/2.16.7/node_modules/graphql-cli/src/cmds/create/index.ts:10:1)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/spencerelliott/Dev/elliottsj/myrepo/common/temp/node_modules/.registry.npmjs.org/graphql-cli/2.16.7/node_modules/graphql-cli/src/cmds/index.ts:7:3)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.installCommands (/Users/spencerelliott/Dev/elliottsj/myrepo/common/temp/node_modules/.registry.npmjs.org/graphql-cli/2.16.7/node_modules/graphql-cli/src/index.ts:49:25)
    at Object.<anonymous> (/Users/spencerelliott/Dev/elliottsj/myrepo/common/temp/node_modules/.registry.npmjs.org/graphql-cli/2.16.7/node_modules/graphql-cli/src/bin.ts:8:1)

i.e. 'tmp' should be declared as a dependency of graphql-cli.

I got the same issue with yarn --pnp

We have just released a new structure for GraphQL CLI in new alpha versions 4.0.0-alpha.XXX.

This was a complete rewrite!

Checkout the new instructions and the migration guide on the docs and let us know your feedback.

Feel free to contact us by opening an issue or using our Discord channel;
https://discord.gg/xud7bH

I've posted the wrong Discord link, this is the correct one: https://discord.gg/xud7bH9

graphql-request should be saved in package.json devDependencies

@vashisth00 this package had a complete rewrite, I think adding graphql-request is no longer relevant