Skip to content

Server tests failed with Node.js 16 #6162

Closed

Description

@Farfurix

Found in https://travis-ci.com/github/testcafe-build-bot/testcafe/jobs/500074387.

module.createRequireFromPath is removed from Node.js v16 after deprecation (v12) (nodejs/node#37201)
Up to v16 we used only this method (src/api/test-controller/execution-context.js):

function createRequire (filename) {
    //Deprecated since: Node v12.2.0
    if (Module.createRequireFromPath)
        return Module.createRequireFromPath(filename);

    if (Module.createRequire) // Reachable only in v16+
        return Module.createRequire(filename);

module.createRequire throws error with the '' filename argument:

> const module = require('module')
undefined
> module.createRequire('')
Uncaught:
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''
    at new NodeError (node:internal/errors:329:5)
    at Function.createRequire (node:internal/modules/cjs/loader:1189:13)
    at REPL22:1:8
    at Script.runInThisContext (node:vm:131:12)
    at REPLServer.defaultEval (node:repl:522:29)
    at bound (node:domain:416:15)
    at REPLServer.runBound [as eval] (node:domain:427:12)
    at REPLServer.onLine (node:repl:844:10)
    at REPLServer.emit (node:events:381:22)
    at REPLServer.emit (node:domain:470:12) {
  code: 'ERR_INVALID_ARG_VALUE'
}

Activity

  1. added
    TYPE: bugThe described behavior is considered as wrong (bug).
    and removed
    TYPE: bugThe described behavior is considered as wrong (bug).
    on Apr 21, 2021
  2. self-assigned this
    on Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions