accounts icon indicating copy to clipboard operation
accounts copied to clipboard

@accounts/magic-link being required even if you're not using it

Open acomito opened this issue 4 years ago • 8 comments

So happy to see @accounts/magic-link implemented!!!

But I think it seems to be required that you install it even if you're not using it?

I just freshly installed accountsjs and it seems to be looking for it.

acomito avatar Jul 31 '21 02:07 acomito

can you paste the code you are using so I can have a look?

pradel avatar Jul 31 '21 09:07 pradel

It also was a required peer dependency for me. Server wouldn't start without it in my package.json even though I have no idea what it is and am not using it.

bmanturner avatar Aug 03 '21 14:08 bmanturner

Sorry for the delay @pradel


  node_modules/@accounts/server/lib/types/email-templates-type.d.ts:8:5
    8     magicLink: EmailTemplateType;
          ~~~~~~~~~
    'magicLink' is declared here.

    at createTSError (/Users/a/Desktop/web-dev/freelance/a/new/backend/node_modules/ts-node/src/index.ts:618:12)
    at reportTSError (/Users/anthony/Desktop/web-dev/freelance/a/new/backend/node_modules/ts-node/src/index.ts:622:19)
    at getOutput (/Users/a/Desktop/web-dev/freelance/a/new/backend/node_modules/ts-node/src/index.ts:809:36)
    at Object.compile (/Users/a/Desktop/web-dev/freelance/a/new/backend/node_modules/ts-node/src/index.ts:1111:30)
    at Module.m._compile (/Users/a/Desktop/web-dev/freelance/apaphani/new/backend/node_modules/ts-node/src/index.ts:1224:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/a/Desktop/web-dev/freelance/a/new/backend/node_modules/ts-node/src/index.ts:1228:12)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
[nodemon] app crashed - waiting for file changes before starting...
    return new TSError(diagnosticText, diagnosticCodes);
           ^
TSError: ⨯ Unable to compile TypeScript:
apollo.ts:42:50 - error TS2345: Argument of type '{ db: Mongo; tokenSecret: string; ambiguousErrorMessages: boolean; tokenConfigs: { accessToken: { expiresIn: string; }; refreshToken: { expiresIn: string; }; }; sendMail: ({ from, subject, to, text, html, }: { from?: string; subject: any; to: any; text: any; html: any; }) => Promise<...>; emailTemplates: { ...; }; s...' is not assignable to parameter of type 'AccountsServerOptions<User>'.
  Types of property 'emailTemplates' are incompatible.
    Property 'magicLink' is missing in type '{ from: string; resetPassword: { subject: () => string; text: () => string; }; passwordChanged: { subject: () => string; text: () => string; }; verifyEmail: { subject: () => string; text: () => string; }; enrollAccount: { ...; }; }' but required in type 'EmailTemplatesType'.

Once I add an email template for it, It then expects to have the package

Error: Cannot find module '@accounts/magic-link'
Require stack:

acomito avatar Aug 08 '21 22:08 acomito

@acomito I fix the issue for the types but can you please paste the rest of the stack for this

Error: Cannot find module '@accounts/magic-link'
Require stack:

it will be helpful to debug

pradel avatar Aug 15 '21 19:08 pradel

It's coming from @accounts/graphql-api

Error: Cannot find module '@accounts/magic-link'
Require stack:
- /project/node_modules/@accounts/graphql-api/lib/modules/accounts-magic-link/index.js
- /project/node_modules/@accounts/graphql-api/lib/modules/accounts/index.js
- /project/node_modules/@accounts/graphql-api/lib/modules/index.js
- /project/node_modules/@accounts/graphql-api/lib/index.js

rohit-gohri avatar Sep 14 '21 17:09 rohit-gohri

Seeing the same issue with magic-link being required by @accounts/graphql-api but not included in the dependencies. Adding it alongside graphql-api fixed it but shouldn't need to do that since my package doesn't directly require it.

brent-hoover avatar Nov 25 '21 03:11 brent-hoover

@zenweasel can we close this issue based on your PR?

acomito avatar Nov 30 '21 14:11 acomito

@acomito the issue is still there, no pr to fix the issue was opened

pradel avatar Nov 30 '21 16:11 pradel