Closed lucperkins closed 4 months ago
I don't quite know what "the require(...) thing." is. Or I did and forgot, probably that.
I take it this slipped through locally but was an issue when deployed? Is there some way to catch it locally or CI?
@colemickens Basically when you're running in Node.js you need to import the node:*
versions of core libraries. node:path
, for example, is basically a wrapper around path
that looks like this:
declare module "node:path" {
import path = require("path");
export = path;
}
This turns an ordinary lib into a module that can be, in turn, compiled into an ESM module. If you don't have this wrapper and you just declare, say, import { join } from "path"
then things crap out at runtime for reasons I admittedly do not fully understand.
Reverted in https://github.com/DeterminateSystems/nix-installer-action/pull/86 because namespace runners were failing with:
::group::Configuring the Docker shim as the Nix Daemon's process supervisor
Configuring the Docker shim as the Nix Daemon's process supervisor
##[debug]Loading image: determinate-nix-shim:latest...
##[debug]open /home/runner/work/magic-nix-cache/docker-shim/arm64.tar.gz: no such file or directory
Error: Error: The process '/usr/bin/docker' failed with exit code 1
(https://github.com/DeterminateSystems/magic-nix-cache/actions/runs/9102189543/job/25021651676)
A gotcha that we need to be mindful of in the future. Whenever we use these built-in Node.js libs we need to import the
node:*
variants lest we get bitten by therequire(...)
thing.