https://supertokens.com/ logo
#general
Title
# general
d

DlyaSeba365

03/24/2022, 8:46 AM
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

03/24/2022, 8:51 AM
Can you send me the error log please?
d

DlyaSeba365

03/24/2022, 8:51 AM
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

03/24/2022, 8:53 AM
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

03/24/2022, 8:55 AM
Yes, without import app works just as usual. Furthermore, i just downloaded it from sapper website so it should be working 100%
r

rp

03/24/2022, 8:55 AM
i see.
What's strange is that the path in the error is not a path that the supertokens lib imports.
d

DlyaSeba365

03/24/2022, 8:56 AM
Yes, I think that is the reason error occurs
r

rp

03/24/2022, 8:56 AM
How are you importing supertokens?
d

DlyaSeba365

03/24/2022, 8:57 AM
import supertokens from "supertokens-node"; import Session from "supertokens-node/recipe/session"; import Passwordless from "supertokens-node/recipe/passwordless";
r

rp

03/24/2022, 8:57 AM
have you done
npm i supertokens-node
?
d

DlyaSeba365

03/24/2022, 8:57 AM
Yessir
r

rp

03/24/2022, 8:58 AM
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

03/24/2022, 8:58 AM
Ok, i'll try to fix it myself and then i'll open an issue
r

rp

03/24/2022, 8:59 AM
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

03/24/2022, 8:59 AM
Ok, i got it
r

rp

03/24/2022, 8:59 AM
thank you!
d

DlyaSeba365

03/24/2022, 9:02 AM
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

03/24/2022, 9:04 AM
Awesome! Glad you got it to work
d

DlyaSeba365

03/24/2022, 9:09 AM
I'll open an issue later
r

rp

03/24/2022, 9:10 AM
cool! thanks
d

DlyaSeba365

03/24/2022, 2:21 PM
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

03/24/2022, 3:49 PM
Hmm. Are you doing server side rendering?
70 Views