graphql-inspector
graphql-inspector copied to clipboard
Cannot find module '@graphql-inspector/graphql-cli-common' in `@graphql-cli/diff`
Describe the bug
Error when trying to generate code w/ graphql-cli
To Reproduce Steps to reproduce the behavior:
- create a new project that uses
GraphQL-CLI
- run the added script
graphql:codegen
- get the following error
$ graphql codegen
(node:44387) UnhandledPromiseRejectionWarning: Error: Cannot find module '@graphql-inspector/graphql-cli-common'
Require stack:
- /path/to/project/node_modules/@graphql-cli/diff/index.cjs.js
- /path/to/project/node_modules/graphql-cli/dist/index.js
- /path/to/project/node_modules/graphql-cli/dist/bin.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/path/to/project/node_modules/@graphql-cli/diff/index.cjs.js:5:26)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at loadCommand (/path/to/project/node_modules/graphql-cli/dist/index.js:46:17)
at Array.map (<anonymous>)
at Object.cli (/path/to/project/node_modules/graphql-cli/dist/index.js:17:68)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:44387) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:44387) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨ Done in 3.43s.
Expected behavior
I expect an error to not be thrown and for it do generate code.
Environment:
- OS: Mac OS 11.1
-
@graphql-cli/diff
-
graphql
: - NodeJS: v12.18.3
Additional context
When going through the stack trace, it is being caused by a missing dependency.
https://github.com/kamilkisiela/graphql-inspector/blob/34c08a68fe3146f95d98f4772f1d0fec15be9b42/packages/graphql-cli/diff/package.json#L30-L35
https://github.com/kamilkisiela/graphql-inspector/blob/34c08a68fe3146f95d98f4772f1d0fec15be9b42/packages/graphql-cli/diff/src/index.ts#L2-L7
I am playing with graphql-cli
and came across the same issue.
Adding that dependency manually to my project made it work, but this is definitely not the way to go.
I'm also facing that issue while playing with graphql-cli...
And when I manually try to add the dependency, it looks like there are some peer deps that cause an issue.
peer graphql-config@"^3.0.0" from @graphql-inspector/[email protected]
but graphql-config is up to at least 4.4.1 now...
Hey @imbayard,
Still happened? We are fixed some issues with peerDependencies
:
- Using
pnpm
- Build the packages with new
bob
version (esm and cjs) - peerDependencies using
workspace: *