Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot seem to get the import to work correctly #45

Closed
chadmott opened this issue Jul 15, 2022 · 5 comments
Closed

cannot seem to get the import to work correctly #45

chadmott opened this issue Jul 15, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@chadmott
Copy link

Type

What kind of issue is this?

[x ] Bug report.
[ ] Feature request.

Description the Issue

No matter how I try this script (vanilla node.js or typescript) I cannot run verify b/c of module issues.

When running as ts-node, I get:

require() of ES Module ...node_modules/azure-ad-verify-token/dist/index.js from index.ts not supported.
to a dynamic import() which is available in all CommonJS modules.

when running in javascript

Cannot find module azure-ad-verify-token/dist/config' imported from ../node_modules/azure-ad-verify-token/dist/index.js

Todo

Try to use the library as illustrated

n/a

Other Information

n/a

@justinlettau
Copy link
Owner

This package is an ESM now. This info here should be what you need. Hope that helps!

@chadmott
Copy link
Author

chadmott commented Jul 15, 2022 via email

@chadmott
Copy link
Author

specifically, when running in node 18.6 with typescript 4.7.4...

tsconfig.json

{
    "compilerOptions": {
      "sourceMap": true,
      "outDir": "dist",
      "strict": true,
      "lib": ["esnext"],
      "esModuleInterop": true,
      "resolveJsonModule": true,
      "suppressImplicitAnyIndexErrors": true,
      "noImplicitAny": false,
      "module": "NodeNext",
    }
  }

package.json

  "type": "module",
  "exports": "./index.ts"

in a project with many other dependencies, yours is the only one I get TSC errors on...


~/tsc

Found 3 errors in the same file, starting at: node_modules/azure-ad-verify-token/dist/index.d.ts:1

node_modules/azure-ad-verify-token/dist/index.d.ts:1:38 - error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './config.js'?

1 export { getConfig, setConfig } from './config';
                                       ~~~~~~~~~~

node_modules/azure-ad-verify-token/dist/index.d.ts:2:24 - error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './verify.js'?

2 export { verify } from './verify';
                         ~~~~~~~~~~

node_modules/azure-ad-verify-token/dist/index.d.ts:3:39 - error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './interfaces.js'?

3 export { Config, VerifyOptions } from './interfaces';
                                        ~~~~~~~~~~~~~~

is this meant to run in node? typescript will not compile this. If you could link to a repo/project that uses typescript and node that would likely be very helpful

@justinlettau justinlettau added the bug Something isn't working label Jul 16, 2022
@justinlettau justinlettau reopened this Jul 16, 2022
@justinlettau
Copy link
Owner

@chadmott Thank you for the extra details! I believe I found the issue .. and it should be fixed in v2.0.1 🎉 Do you mind trying and letting me know? Thanks!

@chadmott
Copy link
Author

Thanks @justinlettau 2.0.1 resolved my issue! appreciate the quick response and helpful links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants