Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: util.isRegExp is not a function in NodeJS v23.0.0 #306

Closed
cunningpike opened this issue Oct 18, 2024 · 4 comments
Closed

TypeError: util.isRegExp is not a function in NodeJS v23.0.0 #306

cunningpike opened this issue Oct 18, 2024 · 4 comments

Comments

@cunningpike
Copy link

After upgrading from NodeJS 20 to NodeJS 23, jsdoc2md v9.0.2 throws a TypeError: util.isRegExp is not a function error when running npx jsdoc2md src/build-index.js > docs/build-index.md.

I have attached the source build-index.js file. The stack trace shows:

> npx jsdoc2md src/build-index.js > docs/build-index.md
(node:26740) ExperimentalWarning: 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)
JSDOC_ERROR: Jsdoc failed.
    at Explain._runJsdoc (file:///C:/Users/rodgersa1/source/repos/Solution-Assessment-Viewer/node_modules/jsdoc-api/lib/explain.js:40:24)
    at async Explain.execute (file:///C:/Users/rodgersa1/source/repos/Solution-Assessment-Viewer/node_modules/jsdoc-api/lib/jsdoc-command.js:57:16)
    at async JsdocToMarkdown.getTemplateData (file:///C:/Users/rodgersa1/source/repos/Solution-Assessment-Viewer/node_modules/jsdoc-to-markdown/index.js:68:23)
    at async JsdocToMarkdown.render (file:///C:/Users/rodgersa1/source/repos/Solution-Assessment-Viewer/node_modules/jsdoc-to-markdown/index.js:54:28) {
  cause: Error: Command failed: node C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\jsdoc.js  -X src/build-index.js
  C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:98
          else if ( util.isRegExp(o) ) {
                         ^

  TypeError: util.isRegExp is not a function
      at ObjectWalker.walk (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:98:24)
      at C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:90:41
      at Array.forEach (<anonymous>)
      at C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:89:21
      at ObjectWalker.checkCircularRefs (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:70:20)
      at ObjectWalker.walk (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:86:27)
      at exports.dump (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:142:44)
      at module.exports.cli.dumpParseResults (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\cli.js:397:50)
      at module.exports.cli.processParseResults (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\cli.js:385:17)
      at module.exports.cli.main (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\cli.js:235:18)
      at module.exports.cli.runCommand (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\cli.js:186:9)
      at C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\jsdoc.js:93:9
      at Object.<anonymous> (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\jsdoc.js:94:3)
      at Module._compile (node:internal/modules/cjs/loader:1568:14)
      at Object..js (node:internal/modules/cjs/loader:1711:10)
      at Module.load (node:internal/modules/cjs/loader:1328:32)

  Node.js v23.0.0

      at genericNodeError (node:internal/errors:983:15)
      at wrappedFn (node:internal/errors:537:14)
      at ChildProcess.exithandler (node:child_process:414:12)
      at ChildProcess.emit (node:events:507:28)
      at maybeClose (node:internal/child_process:1101:16)
      at Socket.<anonymous> (node:internal/child_process:457:11)
      at Socket.emit (node:events:507:28)
      at Pipe.<anonymous> (node:net:343:12) {
    code: 1,
    killed: false,
    signal: null,
    cmd: 'node C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\jsdoc.js  -X src/build-index.js',
    stdout: '',
    stderr: 'C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\lib\\jsdoc\\util\\dumper.js:98\r\n' +
      '        else if ( util.isRegExp(o) ) {\r\n' +
      '                       ^\r\n' +
      '\r\n' +
      'TypeError: util.isRegExp is not a function\r\n' +
      '    at ObjectWalker.walk (C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\lib\\jsdoc\\util\\dumper.js:98:24)\r\n' +
      '    at C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\lib\\jsdoc\\util\\dumper.js:90:41\r\n' +
      '    at Array.forEach (<anonymous>)\r\n' +
      '    at C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\lib\\jsdoc\\util\\dumper.js:89:21\r\n' +
      '    at ObjectWalker.checkCircularRefs (C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\lib\\jsdoc\\util\\dumper.js:70:20)\r\n' +
      '    at ObjectWalker.walk (C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\lib\\jsdoc\\util\\dumper.js:86:27)\r\n' +
      '    at exports.dump (C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\lib\\jsdoc\\util\\dumper.js:142:44)\r\n' +
      '    at module.exports.cli.dumpParseResults (C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\cli.js:397:50)\r\n' +
      '    at module.exports.cli.processParseResults (C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\cli.js:385:17)\r\n' +
      '    at module.exports.cli.main (C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\cli.js:235:18)\r\n' +
      '    at module.exports.cli.runCommand (C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\cli.js:186:9)\r\n' +
      '    at C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\jsdoc.js:93:9\r\n' +
      '    at Object.<anonymous> (C:\\Users\\rodgersa1\\source\\repos\\Solution-Assessment-Viewer\\node_modules\\jsdoc\\jsdoc.js:94:3)\r\n' +
      '    at Module._compile (node:internal/modules/cjs/loader:1568:14)\r\n' +
      '    at Object..js (node:internal/modules/cjs/loader:1711:10)\r\n' +
      '    at Module.load (node:internal/modules/cjs/loader:1328:32)\r\n' +
      '\r\n' +
      'Node.js v23.0.0\r\n'
  }
}

The error appears to come from jsdoc -X src/build-index.js, validated by the following:

> npx jsdoc -X src/build-index.js
(node:21956) ExperimentalWarning: 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)
C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:98
        else if ( util.isRegExp(o) ) {
                       ^

TypeError: util.isRegExp is not a function
    at ObjectWalker.walk (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:98:24)
    at C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:90:41
    at Array.forEach (<anonymous>)
    at C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:89:21
    at ObjectWalker.checkCircularRefs (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:70:20)
    at ObjectWalker.walk (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:86:27)
    at exports.dump (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\lib\jsdoc\util\dumper.js:142:44)
    at module.exports.cli.dumpParseResults (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\cli.js:397:50)
    at module.exports.cli.processParseResults (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\cli.js:385:17)
    at module.exports.cli.main (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\cli.js:235:18)
    at module.exports.cli.runCommand (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\cli.js:186:9)
    at C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\jsdoc.js:93:9
    at Object.<anonymous> (C:\Users\rodgersa1\source\repos\Solution-Assessment-Viewer\node_modules\jsdoc\jsdoc.js:94:3)
    at Module._compile (node:internal/modules/cjs/loader:1568:14)
    at Object..js (node:internal/modules/cjs/loader:1711:10)
    at Module.load (node:internal/modules/cjs/loader:1328:32)

Node.js v23.0.0

The weird thing is that ./node_modules/util/util.js exists and contains the following function:

function isRegExp(re) {
  return isObject(re) && objectToString(re) === '[object RegExp]';
}
exports.isRegExp = isRegExp;

The error occurs both on my development machine (Windows 11/VSCode) and in the following pipeline:

  doc-gen:
    permissions:
      contents: write
    runs-on: ubuntu-latest
    env:
      NODE_ENV: development
    steps:
      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: latest
      - name: Checkout
        uses: actions/checkout@v4
      - name: Package Install
        run: npm ci
      - name: vue-docgen
        run: npx vue-docgen
      - name: jsdoc-md
        run: npx jsdoc2md src/build-index.js > docs/build-index.md

The previous command npx vue-docgen works fine.

build-index.js.txt

@75lb
Copy link
Member

75lb commented Oct 18, 2024

Hi, thanks for letting me know. This is a jsdoc issue, I have reported it and will monitor.

@75lb
Copy link
Member

75lb commented Oct 19, 2024

Given the urgency, and the typically slow response time for jsdoc issues, I forked and patched jsdoc, published a temp hotfix module and released new versions of jsdoc2md and jsdoc-api which use it.

Please update your jsdoc2md. Leaving this issue open until an official jsdoc solution is available.

@hegemonic
Copy link

This issue is fixed in JSDoc 4.0.4.

75lb added a commit to jsdoc2md/jsdoc-api that referenced this issue Oct 19, 2024
75lb added a commit that referenced this issue Oct 19, 2024
@75lb
Copy link
Member

75lb commented Oct 19, 2024

Many thanks for the quick fix @hegemonic! This is now fixed and released in jsdoc-api and jsdoc-to-markdown too.

@75lb 75lb closed this as completed Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants