filemonczyk
filemonczyk

Reputation: 1703

Import not working with typescript

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

Upvotes: 1

Views: 3460

Answers (1)

Matt McCutchen
Matt McCutchen

Reputation: 30899

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';

Upvotes: 6

Related Questions