Can't compile with Nuxt / Node 16.x and dd-trace 2.x
ERROR Failed to compile with 27 errors friendly-errors 16:45:56
These dependencies were not found: friendly-errors 16:45:56
friendly-errors 16:45:56
* async_hooks in ./node_modules/dd-trace/packages/datadog-core/src/storage/async_resource.js, ./node_modules/dd-trace/packages/datadog-instrumentations/src/helpers/instrument.js and 1 other
* child_process in ./node_modules/@datadog/native-appsec/node_modules/detect-libc/lib/detect-libc.js, ./node_modules/dd-trace/packages/dd-trace/src/plugins/util/exec.js
* dgram in ./node_modules/dd-trace/packages/dd-trace/src/dogstatsd.js friendly-errors 16:45:56
* dns in ./node_modules/dd-trace/packages/datadog-instrumentations/src/net.js, ./node_modules/dd-trace/packages/dd-trace/src/dogstatsd.js
* fs in ./node_modules/@datadog/native-appsec/node_modules/detect-libc/lib/detect-libc.js, ./node_modules/@datadog/pprof/node_modules/source-map/lib/read-wasm.js and 10 others
* graphql/language/printer in ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js
* graphql/language/visitor in ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js
* graphql/utilities in ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js
* module in ./node_modules/dd-trace/packages/dd-trace/src/ritm.js friendly-errors 16:45:56
* net in ./node_modules/dd-trace/packages/dd-trace/src/dogstatsd.js friendly-errors 16:45:56
* v8 in ./node_modules/dd-trace/packages/dd-trace/src/metrics.js friendly-errors 16:45:56
* ~/locales in ./plugins/i18n.js friendly-errors 16:45:56
friendly-errors 16:45:56
To install them, you can run: npm install --save async_hooks child_process dgram dns fs graphql/language/printer graphql/language/visitor graphql/utilities module net v8 ~/locales
Environment
- Operation system:
- mac 12.4 (21F79)
- Node.js version:
- 16.15.0
- Tracer version:
- Agent version:
- Relevant library versions: "dd-trace": "^2.11.0",
initialisation script: ( used to work fine for dd-trace 0.x.x )
const tracer = require('dd-trace')
export default function Datadog() {
tracer.init({
hostname: process.env.DD_AGENT_HOST,
service: 'purchaser/index-pages',
env: process.env.STAGE,
logInjection: true,
})
}
const tracer = require('dd-trace')
const formats = require('dd-trace/ext/formats')
export default (_, inject) => {
function logger(level, payload, message) {
const span = tracer.scope().active()
const time = new Date().toISOString()
const record = { time, level, ...payload, message }
if (span) {
tracer.inject(span.context(), formats.LOG, record)
}
console.log(record)
}
inject('logger', logger)
}
There are a lot of Node built-in modules that are not available, which shouldn't be possible in Node. Is this a browser build? If that's the case, browsers are not supported by this library and the browser SDK should be used instead in those environments.
it's an SSR server/client framework (Nuxt) but I assume I'll need to restrict this to server-side? (weird, we didn't explicitly needed to do this for the older dd-trace versions)
Yes, it should be restricted to the server. Some versions used to "run" in the browser in the sense that it would transpile and not necessarily error, but they would not be generating traces. Some very old versions used to also support the browser explicitly but that support has been replaced by the browser SDK since RUM is better suited for browser observability.
It looks like this issue was wrapped up. If I'm misunderstanding feel free to reopen and tag us.