Giter Site home page Giter Site logo

clerk-sdk-node-named-exports-repro's Introduction

clerk-sdk-node import error

See clerk/javascript#1375

Starting with @clerk/[email protected], named exports are not working when running our app using tsx.

This repo is a minimal reproduction. It has two directories: working and broken. The only difference between the two is the version of @clerk/clerk-sdk-node in package.json:

Working example

$ cd working
$ npm i
$ cat index.ts

import { sessions } from '@clerk/clerk-sdk-node'
console.log(sessions)

$ npm run start

> start
> tsx index.ts

xe { request: [AsyncFunction (anonymous)] }

Broken example

$ cd broken
$ npm i
$ cat index.ts

import { sessions } from '@clerk/clerk-sdk-node'
console.log(sessions)

$ npm run start

> start
> tsx index.ts

SyntaxError: The requested module '@clerk/clerk-sdk-node' does not provide an export named 'sessions'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:128:21)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ModuleJob.run (node:internal/modules/esm/module_job:194:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)

Workaround

Changing from a named export to a default export works around the issue:

import clerk from "@clerk/clerk-sdk-node";
const { sessions } = clerk;

Environment

  • Node: Tested in both Node 16.15.0 and 20.3.0 with the same results.
  • OS: Arch Linux

clerk-sdk-node-named-exports-repro's People

Contributors

b0o avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.