Skip to content

Commit 04e9822

Browse files
committed
patch: fix compatibility issue on node 23+ (including LTS version node 24)
reference tensorflow/tfjs#8425
1 parent 9bbb1a2 commit 04e9822

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

polyfill.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Polyfill the removed util.isNullOrUndefined (Node 23+ broke tfjs-node < ~4.23)
2+
let util = require('util')
3+
4+
// Only patch if the function is missing
5+
if (typeof util.isNullOrUndefined !== 'function') {
6+
util.isNullOrUndefined = (val: any) => val === null || val === undefined
7+
}
8+
9+
// Optional: also patch isUndefined / isDefined if you see similar errors later
10+
if (typeof util.isUndefined !== 'function') {
11+
util.isUndefined = (val: any) => val === undefined
12+
}
13+
14+
if (typeof util.isDefined !== 'function') {
15+
util.isDefined = (val: any) => val !== undefined
16+
}

server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './polyfill'
12
import express from 'express'
23
import { print } from 'listening-on'
34
import { main as train } from './train'

0 commit comments

Comments
 (0)