Skip to content

Can't resolve 'graphql/language/visitor' when bundling using webpack for node target #2413

@SKoschnicke

Description

@SKoschnicke

Expected behaviour
I'm trying to add the dd-trace library to our Node.js express application, which is written in Typescript and build using Webpack.
I followed these docs: https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/nodejs/?tab=otherenvironments#instrument-your-application
I expect the application to build just fine using Webpack, as it was the case before adding the dd-trace library.

Actual behaviour
I'm getting the following build errors:

yarn run v1.22.19
warning package.json: No license field
$ webpack
asset bundle.js 2.57 MiB [emitted] (name: main)
runtime modules 1.04 KiB 5 modules
cacheable modules 2.05 MiB 476 modules
+ 27 modules

WARNING in ./node_modules/express/lib/view.js 81:13-25
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/express/lib/application.js 22:11-28
 @ ./node_modules/express/lib/express.js 18:12-36
 @ ./node_modules/express/index.js 11:0-41
 @ ./index.ts 2:0-35 3:10-17

1 warning has detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

ERROR in ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js 9:18-53
Module not found: Error: Can't resolve 'graphql/language/visitor' in '/Users/sven/development/ct/datadog/node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools'
 @ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/signature.js 6:21-44
 @ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/index.js 6:18-40
 @ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/index.js 219:25-43
 @ ./node_modules/dd-trace/packages/dd-trace/src/plugins/index.js 26:28-74
 @ ./node_modules/dd-trace/packages/dd-trace/src/plugin_manager.js 5:16-36
 @ ./node_modules/dd-trace/packages/dd-trace/src/proxy.js 10:22-49
 @ ./node_modules/dd-trace/packages/dd-trace/src/index.js 10:4-22
 @ ./node_modules/dd-trace/packages/dd-trace/index.js 4:22-38
 @ ./node_modules/dd-trace/index.js 3:0-47
 @ ./node_modules/dd-trace/init.js 3:15-27
 @ ./index.ts 1:0-23

ERROR in ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js 10:18-53
Module not found: Error: Can't resolve 'graphql/language/printer' in '/Users/sven/development/ct/datadog/node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools'
 @ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/signature.js 6:21-44
 @ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/index.js 6:18-40
 @ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/index.js 219:25-43
 @ ./node_modules/dd-trace/packages/dd-trace/src/plugins/index.js 26:28-74
 @ ./node_modules/dd-trace/packages/dd-trace/src/plugin_manager.js 5:16-36
 @ ./node_modules/dd-trace/packages/dd-trace/src/proxy.js 10:22-49
 @ ./node_modules/dd-trace/packages/dd-trace/src/index.js 10:4-22
 @ ./node_modules/dd-trace/packages/dd-trace/index.js 4:22-38
 @ ./node_modules/dd-trace/index.js 3:0-47
 @ ./node_modules/dd-trace/init.js 3:15-27
 @ ./index.ts 1:0-23

ERROR in ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js 11:20-48
Module not found: Error: Can't resolve 'graphql/utilities' in '/Users/sven/development/ct/datadog/node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools'
 @ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/signature.js 6:21-44
 @ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/index.js 6:18-40
 @ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/index.js 219:25-43
 @ ./node_modules/dd-trace/packages/dd-trace/src/plugins/index.js 26:28-74
 @ ./node_modules/dd-trace/packages/dd-trace/src/plugin_manager.js 5:16-36
 @ ./node_modules/dd-trace/packages/dd-trace/src/proxy.js 10:22-49
 @ ./node_modules/dd-trace/packages/dd-trace/src/index.js 10:4-22
 @ ./node_modules/dd-trace/packages/dd-trace/index.js 4:22-38
 @ ./node_modules/dd-trace/index.js 3:0-47
 @ ./node_modules/dd-trace/init.js 3:15-27
 @ ./index.ts 1:0-23

3 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.74.0 compiled with 3 errors and 1 warning in 1167 ms
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

(there is by the way a bug in your issue template, as it says here under actual behaviour <!-- What should be happening. -->)

Steps to reproduce
I created a demo project which also produces the above errors:
https://github.com/SKoschnicke/datadog-test

Just clone it and do yarn install and then yarn build.

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbundler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions