launchdarkly / js-core

LaunchDarkly monorepo for JavaScript SDKs
Other
14 stars 18 forks source link

SDK client initialization throws error #118

Closed gsheppard closed 1 year ago

gsheppard commented 1 year ago

Describe the bug

When initializing the client, I get TypeError: Native module not found: ../package.json. I believe it's because of this file, which has a different relative location to the package.json when compiled to CJS+ESM.

To reproduce

import LaunchDarkly from '@launchdarkly/vercel-server-sdk'
import { createClient } from '@vercel/edge-config'

export const config = {
  matcher: '/((?!api|static|.*\\..*|_next|_vercel).*)',
}

export async function middleware() {
  const edgeClient = createClient(process.env.EDGE_CONFIG)
  const ldClient = LaunchDarkly.init('sdk-8e0b47f2-9422-43b0-969b-e36583872175', edgeClient)

  return NextResponse.next()
}

Expected behavior That the client would not throw an error.

SDK version

"@launchdarkly/vercel-server-sdk": "^0.2.2",
"@vercel/edge-config": "^0.1.10",

Language version, developer tools

kinyoklion commented 1 year ago

Hello @gsheppard,

Thank you for reporting this issue. It should be fixed in 0.3.0.

Thanks, Ryan