FaasJS
Home
  • Guide
  • Documents
  • Starter Template
  • Changelog
  • Ecosystem

    • VS Code Plugin
    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security
  • English
  • 简体中文
Home
  • Guide
  • Documents
  • Starter Template
  • Changelog
  • Ecosystem

    • VS Code Plugin
    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security
  • English
  • 简体中文

Documents / @faasjs/load / detectNodeRuntime

Function: detectNodeRuntime()

detectNodeRuntime(): NodeRuntime

Detect the current JavaScript runtime environment.

This function checks for the presence of import.meta and require to determine whether the runtime is using ECMAScript modules (ESM) or CommonJS modules (CJS).

Returns

NodeRuntime

  • Returns 'module' if the runtime is using ECMAScript modules, and 'cjs' if the runtime is using CommonJS modules.

Throws

  • Throws an error if the runtime cannot be determined.