Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit d0f0494

Browse files
authored
fix: do not use import on package.json (#1932)
* fix: do not use import on package.json * add additional logic around require for package.json * fix path
1 parent d38dc73 commit d0f0494

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/nodejs-common/util.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ import {Duplex, DuplexOptions, Readable, Transform, Writable} from 'stream';
2929
import {teenyRequest} from 'teeny-request';
3030
import {Interceptor} from './service-object';
3131
import * as uuid from 'uuid';
32-
import * as packageJson from '../../package.json';
32+
let packageJson: ReturnType<JSON['parse']> = {};
33+
try {
34+
// if requiring from 'build' (default)
35+
packageJson = require('../../../package.json');
36+
} catch (e) {
37+
// if requiring directly from TypeScript context
38+
packageJson = require('../../package.json');
39+
}
3340

3441
// eslint-disable-next-line @typescript-eslint/no-var-requires
3542
const duplexify: DuplexifyConstructor = require('duplexify');

0 commit comments

Comments
 (0)