fix: expose npm binary in toolchain files

Fixes #3844
diff --git a/e2e/smoke/BUILD.bazel b/e2e/smoke/BUILD.bazel
index c902e09..afbe966 100644
--- a/e2e/smoke/BUILD.bazel
+++ b/e2e/smoke/BUILD.bazel
@@ -184,6 +184,14 @@
     target_compatible_with = not_windows,
 )
 
+genrule(
+    name = "npm_help",
+    outs = ["help.txt"],
+    cmd = "$(NPM_PATH) --help > $@ || true",
+    toolchains = ["@nodejs_toolchains//:resolved_toolchain"],
+    tools = ["@nodejs_toolchains//:resolved_toolchain"],
+)
+
 ################################################
 # Tests and setup for the toolchain changes
 
diff --git a/nodejs/toolchain.bzl b/nodejs/toolchain.bzl
index 6163d10..e64581f 100644
--- a/nodejs/toolchain.bzl
+++ b/nodejs/toolchain.bzl
@@ -83,9 +83,10 @@
         "NODE_PATH": ctx.file.node.path if ctx.attr.node else ctx.attr.node_path,
         "NPM_PATH": ctx.file.npm.path if ctx.attr.npm else ctx.attr.npm_path,
     })
+    files = [getattr(ctx.file, f) for f in ["node", "npm"] if f]
     default = DefaultInfo(
-        files = depset([ctx.file.node]) if ctx.attr.node else depset(),
-        runfiles = ctx.runfiles(files = [ctx.file.node] if ctx.attr.node else []),
+        files = depset(files),
+        runfiles = ctx.runfiles(files = files),
     )
     npm_sources = depset([ctx.file.npm] + ctx.files.npm_srcs)
     nodeinfo = NodeInfo(