1212# USAGE: [TARGET_NODE_MAJOR=22] ./scripts/install_deps.sh [extra yarn args...]
1313#
1414# TARGET_NODE_MAJOR defaults to the Node major running this script. Set it
15- # explicitly when the host Node version differs from the runtime being built
16- # for, e.g. the GitLab CI image runs Node 18 but builds for every runtime.
15+ # when the host differs from the runtime being built for (e.g. Node 22
16+ # packing a Node 18 fixture, which pins v5). Installing v6 still requires
17+ # a host of Node 22+ so native prebuilds resolve.
1718
1819set -e
1920
@@ -29,9 +30,19 @@ if [ -z "$TARGET_NODE_MAJOR" ]; then
2930fi
3031
3132dd_trace_override=$( dd_trace_version_for_node_major " $TARGET_NODE_MAJOR " )
33+ host_major=$( node -p " process.versions.node.split('.')[0]" )
3234
33- # --ignore-engines is needed on both paths: dd-trace v6 refuses to install on
34- # hosts older than Node 22 even when it is only being built for a newer runtime.
35+ # v6's optional native addons (pprof, appsec, oxc-parser) ship prebuilds for
36+ # Node 22+ only. --ignore-engines would let yarn extract the tarball on
37+ # Node 18, then node-gyp-build fails and the tree is unusable. Pin v5 instead.
38+ if [ -z " $dd_trace_override " ] && [ " $host_major " -lt " $DD_TRACE_V6_MIN_NODE_MAJOR " ]; then
39+ echo " dd-trace v6 cannot be installed on Node ${host_major} (engines.node >= ${DD_TRACE_V6_MIN_NODE_MAJOR} )." >&2
40+ echo " Use Node ${DD_TRACE_V6_MIN_NODE_MAJOR} +, or set TARGET_NODE_MAJOR to 18 or 20 to pin v5." >&2
41+ exit 1
42+ fi
43+
44+ # Nested packages still declare engines that reject some hosts; yarn 1
45+ # otherwise fails the whole install on an engines mismatch.
3546yarn_args=(" --ignore-engines" )
3647
3748if [ -n " $dd_trace_override " ]; then
0 commit comments