Skip to content

[BUG] (node:63871) ExperimentalWarning: CommonJS module using require() #7942

Closed
@songyang-dev

Description

Is there an existing issue for this?

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

Running npm creates a warning. My installation comes from Homebrew. When I reinstalled the newest version 10.9.1 with the URL in the README, it is still printing the warning.

-> % npm init
(node:64208) ExperimentalWarning: CommonJS module /opt/homebrew/Cellar/node/23.3.0/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /opt/homebrew/Cellar/node/23.3.0/lib/node_modules/npm/node_modules/supports-color/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (test) npm warn init canceled

Audit creates a different error code.

-> % npm audit
(node:63871) ExperimentalWarning: CommonJS module /opt/homebrew/Cellar/node/23.3.0/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /opt/homebrew/Cellar/node/23.3.0/lib/node_modules/npm/node_modules/supports-color/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
found 0 vulnerabilities

Expected Behavior

No warnings

Steps To Reproduce

  1. Create a folder and cd into it.
  2. npm init.

Environment

  • npm: 10.9.1
  • Node.js: v23.3.0
  • OS Name: MacOS 15.1.1
  • System Model Name: MacBook Air
  • npm config:
; node bin location = /opt/homebrew/Cellar/node/23.3.0/bin/node
; node version = v23.3.0
; npm local prefix = /Users/songyang/Desktop/test
; npm version = 10.9.1
; cwd = /Users/songyang/Desktop/test
; HOME = /Users/songyang
; Run `npm config ls -l` to show all defaults.

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions