Hello Everyone, I'm new to SuperTokens, right now ...
# general
d
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
Can you send me the error log please?
d
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
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
Yes, without import app works just as usual. Furthermore, i just downloaded it from sapper website so it should be working 100%
r
i see.
What's strange is that the path in the error is not a path that the supertokens lib imports.
d
Yes, I think that is the reason error occurs
r
How are you importing supertokens?
d
import supertokens from "supertokens-node"; import Session from "supertokens-node/recipe/session"; import Passwordless from "supertokens-node/recipe/passwordless";
r
have you done
npm i supertokens-node
?
d
Yessir
r
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
Ok, i'll try to fix it myself and then i'll open an issue
r
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
Ok, i got it
r
thank you!
d
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
Awesome! Glad you got it to work
d
I'll open an issue later
r
cool! thanks
d
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
Hmm. Are you doing server side rendering?
76 Views