Mike K
Mike K

Reputation: 6491

Using imports with Nodejs doesn't recognize a default export

I'm using expo-server-sdk, and I haven't had this issue with other packages yet, but I'm thinking that this isn't an issue specific to this package.

Basically, my IDE recognises that this package has a default export, and correctly autoimports it as,

import { Expo } from 'expo-server-sdk';

The problem is that this doesn't compile and throws the error,

SyntaxError: The requested module 'expo-server-sdk' does not provide an export named 'Expo'

I'm using the experimental ESM module loader with Node v13.13.0. When I initially set up the config and environment, I was able to use import instead of require, however I am supposed to append the extension of each file I import.

What can be wrong here?

Expo post for reference

Upvotes: 0

Views: 347

Answers (2)

Mike K
Mike K

Reputation: 6491

I managed to work around this by doing the following:

import Expo from 'expo-server-sdk';

...
let expo = Expo.Expo()
...
if (!Expo.Expo.isExpoPushToken(pushToken)) {
   ... 
}
...

Just import Expo from 'expo-server-sdk'; did not work.

Upvotes: 0

Arun Mohan
Arun Mohan

Reputation: 1227

If it's exported as default you only need

import Expo from 'expo-server-sdk';

instead of

import { Expo } from 'expo-server-sdk';

Upvotes: 1

Related Questions