denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.91k stars 5.39k forks source link

The requested module 'node:module' does not provide an export named 'register' #24902

Closed creonico closed 3 months ago

creonico commented 3 months ago

Version: Deno 1.45.5

I have the following script that sets up payloadcms for a new project and a deno.json with the dependency and tasks:

// server.ts
import { getPayload } from 'payload';
import { importConfig } from 'payload/node';
{
  "nodeModulesDir": false,
  "tasks": {
    "seed": "deno run server.ts"
  },
  "imports": {
    "@payloadcms/db-postgres": "npm:@payloadcms/db-postgres@3.0.0-beta.73",
    "payload": "npm:payload@3.0.0-beta.73"
  }
}

But when I run it, it gives the following error:

Task seed deno run server.ts
error: Uncaught SyntaxError: The requested module 'node:module' does not provide an export named 'register'
    at <anonymous> (file:.../deno/npm/registry.npmjs.org/payload/3.0.0-beta.73/dist/utilities/importWithoutClientFiles.js:1:10)

Which points to this line:

// importWithoutClientFiles.js
import { register } from 'node:module';

But the node version v20.12.2 does export register from node:module, https://nodejs.org/docs/latest-v20.x/api/module.html#moduleregisterspecifier-parenturl-options. Am I missing something or am I right to believe that this is a bug with 'node:' specifiers?

Kiranism commented 3 months ago

But the node version v20.12.2 does export register from node:module, https://nodejs.org/docs/latest-v20.x/api/module.html#moduleregisterspecifier-parenturl-options. Am I missing something or am I right to believe that this is a bug with 'node:' specifiers?

I was facing a similar bug, and thank you for mentioning the Node version—now I’ve got it working