cli icon indicating copy to clipboard operation
cli copied to clipboard

globalThis.process.getBuiltinModule is not a function

Open BlueBazze opened this issue 3 months ago • 3 comments

I've set up a new project today,

Dependencies

{
  "dependencies": {
    "@nuxt/fonts": "0.11.4",
    "@nuxt/icon": "2.0.0",
    "@nuxt/image": "1.11.0",
    "@nuxt/ui": "^4.0.1",
    "@nuxthub/core": "0.9.0",
    "drizzle-orm": "^0.44.6",
    "nuxt": "4.1.3",
    "nuxt-auth-utils": "^0.5.25",
    "vue": "^3.5.22",
    "vue-router": "^4.5.1"
  },
  "devDependencies": {
    "drizzle-kit": "^0.31.5",
    "wrangler": "^4.42.1"
  }
}

The only hub features enabled is database & blob Experimental nuxt features typedPages

The errors that were thrown

 ERROR  Fetch handler error: globalThis.process.getBuiltinModule is not a function                                                                                                                                                      22.48.35  

    at get _request [as _request] (/C:/.../MyNuxtProject/node_modules/srvx/dist/adapters/node.mjs:153:61)
    at desc.get [as body] (/C:/.../MyNuxtProject/node_modules/srvx/dist/_chunks/_inherit-DLZfB57K.mjs:10:16)
    at fetchAddress (/C:/.../MyNuxtProject/node_modules/@nuxt/cli/dist/chunks/dev.mjs:125:19)
    at Server.<anonymous> (/C:/.../MyNuxtProject/node_modules/@nuxt/cli/dist/chunks/dev.mjs:189:33)
    at Server.emit (node:events:531:35)
    at parserOnIncoming (node:_http_server:1137:12)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)


 ERROR  Fetch handler error: Premature close                                                                                                                                                                                            22.49.20  

    at onclose (node:internal/streams/end-of-stream:159:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)


 ERROR  [unhandledRejection] Cannot set headers after they are sent to the client                                                                                                                                                       22.49.20  

    at ServerResponse.setHeader (node:_http_outgoing:703:11)
    at renderError (/C:/.../MyNuxtProject/node_modules/@nuxt/cli/dist/chunks/index.mjs:67:7)
    at res.statusCode (/C:/.../MyNuxtProject/node_modules/@nuxt/cli/dist/chunks/dev.mjs:449:7)
    at Server.<anonymous> (/C:/.../MyNuxtProject/node_modules/@nuxt/cli/dist/chunks/dev.mjs:193:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

I have narrowed it down to somewhere in 3.29.x while also thinking globalThis.process.getBuiltinModule was the main issue. https://github.com/nuxt/cli/commit/fa5d5e6 https://github.com/h3js/srvx/pull/117

Overriding nuxt/cli to 3.28.0 re-removes the srvx package and the errors above are not thrown.

BlueBazze avatar Oct 08 '25 21:10 BlueBazze

can you refresh your lockfile?

I believe this has been fixed upstream in srvx

danielroe avatar Oct 09 '25 07:10 danielroe

Just tried removing the version override for nuxt/cli.

Looking at my bun.lock nuxt/cli depends on "srvx": "^0.8.9" srvx resolves to [email protected]

0.8.15 seems to be the latest

Errors thrown when useFetch on a post request.

 ERROR  Fetch handler error: Premature close                                                                                                                                                                           22.06.13  

    at onclose (node:internal/streams/end-of-stream:159:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)


 ERROR  Fetch handler error: globalThis.process.getBuiltinModule is not a function                                                                                                                                     22.06.19  

    at get _request [as _request] (/C:/.../MyNuxtProject/node_modules/srvx/dist/adapters/node.mjs:153:61)
    at desc.get [as body] (/C:/.../MyNuxtProject/node_modules/srvx/dist/_chunks/_inherit-DLZfB57K.mjs:10:16)
    at fetchAddress (/C:/.../MyNuxtProject/node_modules/@nuxt/cli/dist/chunks/dev.mjs:140:19)
    at Server.<anonymous> (/C:/.../MyNuxtProject/node_modules/@nuxt/cli/dist/chunks/dev.mjs:232:33)
    at Server.emit (node:events:531:35)
    at parserOnIncoming (node:_http_server:1137:12)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)

Another route that serves NuxtHub Blob, is only throwing the Premature close error

export default eventHandler(async (event) => {
  const { blobKey } = getRouterParams(event);


  return hubBlob().serve(event, blobKey);
});

I can provide you with the small codebase im working with.

BlueBazze avatar Oct 09 '25 20:10 BlueBazze

I also got this error (Fetch handler error: globalThis.process.getBuiltinModule is not a function) when working with Nuxt's server framework.

UPD: solution

GentIeman avatar Oct 20 '25 11:10 GentIeman