1

I'm importing object to a .ts file but it is undefined, when I do the same with require keyword , then it is working. But I'd like to understand whats happening

const jwt = require('jsonwebtoken'); // working
import {jwt2} from 'jsonwebtoken'; // not working

1 Answer 1

6

The first example is importing the entire module, while the second one is trying to import a member of the module named jwt2, but there is no such member. To import the entire module using import, try:

import * as jwt2 from 'jsonwebtoken';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.