Skip to content

[Node.js 23.x] CJS module gulp-cli\lib\shared\require-or-import.js is loading ESM gulpfile.js using require() #267

@CedX

Description

@CedX

Before you open this issue, please complete the following tasks:

  • use the search bar at the top of the page to search this repository for similar issues or discussions that have already been opened.
  • if you are looking for help from the gulp team or community, open a discussion.
  • if you think there is a problem with the plugin you're using, open a discussion.
  • if you think there is a bug in our code, open this issue.

What were you expecting to happen?

Launching a Gulp task doesn't produce any warning.

What actually happened?

Since Node.js v23, an ExperimentalWarning is triggered.

This is because the requireOrImport() function uses require() to check if the gulpfile is a CommonJS module... but now Node.js allows to use require() for loading ES modules. So the ERR_REQUIRE_ESM error is not triggered anymore.

See: https://nodejs.org/en/blog/release/v23.0.0

Please give us a sample of your gulpfile

This issue is not related to the content of the gulpfile.
But feel free to test this project: https://github.com/cedx/lcov.js

Terminal output / screenshots

(node:26792) ExperimentalWarning: CommonJS module [...]\gulp-cli\lib\shared\require-or-import.js is loading ES Module [...]\gulpfile.js using require().

Please provide the following information:

  • OS & version [e.g. MacOS Catalina 10.15.4]: Windows 11
  • node version (run node -v): 23.1.0
  • npm version (run npm -v): 10.9.0
  • gulp version (run gulp -v): CLI version: 3.0.0, Local version: 5.0.0

Additional information

The launched tasks still run fine (unless the gulpfile uses top-level await). There is no runtime error, just an ExperimentalWarning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions