From 571a230b3cf3f525a766330b6c01350ddeff6c9f Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Mon, 4 Nov 2024 20:09:16 +0100 Subject: [PATCH] fix require is not defined in ES module scope --- lib/lnd.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/lnd.js b/lib/lnd.js index aa58b33c..b9d37954 100644 --- a/lib/lnd.js +++ b/lib/lnd.js @@ -5,12 +5,15 @@ import { join } from 'path' import apiForProto from 'lightning/lnd_grpc/api_for_proto' import { defaultSocket, grpcSslCipherSuites, packageTypes, protoFiles, protosDir, serviceTypes } from 'lightning/grpc/index' import grpcCredentials from 'lightning/lnd_grpc/grpc_credentials' +import { createRequire } from 'module' const { GRPC_SSL_CIPHER_SUITES } = process.env const { keys } = Object export function authenticatedLndGrpc ({ cert, macaroon, path, socket }, withProxy) { - const lightningModulePath = require.resolve('lightning') + const req = createRequire(import.meta.url) + + const lightningModulePath = req.resolve('lightning') const pathForProto = proto => join(lightningModulePath, protosDir, proto) const { credentials } = grpcCredentials({ cert, macaroon })