Thread
#general
    d

    DlyaSeba365

    6 months ago
    Hello Everyone, I'm new to SuperTokens, right now I'm trying to get it work with Sapper app and importing "supertokens-node/recipe/session" crashes my server somehow. Does anybody have any idea why this would happen?
    r

    rp

    6 months ago
    Can you send me the error log please?
    d

    DlyaSeba365

    6 months ago
    Yes
    Unexpected token (Note that you need @rollup/plugin-json to import JSON files) 1: { 2: "application/1d-interleaved-parityfec": { ^ 3: "source": "iana" 4: }, internal/modules/cjs/loader.js:905 throw err; ^ Error: Cannot find module '/home/yulaj/Desktop/sapper-supertokens/sapper/dev/server/server.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15) at Function.Module._load (internal/modules/cjs/loader.js:746:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }
    Server crashed
    I guess the error is related to namespacing
    It is trying to import package with wrong path
    r

    rp

    6 months ago
    idk if this is an error to do with supertokens or an incorrect import in your app. Does this error go away when you comment out supertokens import?
    d

    DlyaSeba365

    6 months ago
    Yes, without import app works just as usual. Furthermore, i just downloaded it from sapper website so it should be working 100%
    r

    rp

    6 months ago
    i see.
    What's strange is that the path in the error is not a path that the supertokens lib imports.
    d

    DlyaSeba365

    6 months ago
    Yes, I think that is the reason error occurs
    r

    rp

    6 months ago
    How are you importing supertokens?
    d

    DlyaSeba365

    6 months ago
    import supertokens from "supertokens-node"; import Session from "supertokens-node/recipe/session"; import Passwordless from "supertokens-node/recipe/passwordless";
    r

    rp

    6 months ago
    have you done
    npm i supertokens-node
    ?
    d

    DlyaSeba365

    6 months ago
    Yessir
    r

    rp

    6 months ago
    can you open an issue about this on our github? We can have a look at it
    Im not sure what the solution is rigth now
    d

    DlyaSeba365

    6 months ago
    Ok, i'll try to fix it myself and then i'll open an issue
    r

    rp

    6 months ago
    sounds good. If you do figure it out, then it would still be good to open an issue and write the solution in there for future users 🙂
    d

    DlyaSeba365

    6 months ago
    Ok, i got it
    r

    rp

    6 months ago
    thank you!
    d

    DlyaSeba365

    6 months ago
    Well, I figured it out
    Turns out the problem is related to rollup which is used in sapper
    To properly import supertokens in server.js you should do this - https://linguinecode.com/post/rollup-plugin-json-import
    n

    nkshah2

    6 months ago
    Awesome! Glad you got it to work
    d

    DlyaSeba365

    6 months ago
    I'll open an issue later
    r

    rp

    6 months ago
    cool! thanks
    d

    DlyaSeba365

    6 months ago
    There is another error related to Sapper
    In the same file after fixing error below, I get - Error: Please call the supertokens.init function before using SuperTokens
    Despite the fact, that I call this function with all required parameters
    Fun thing is that If I call this function double time but one without "framework" parameter error changes
    r

    rp

    6 months ago
    Hmm. Are you doing server side rendering?