简体   繁体   中英

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

If it's exported as default you only need

import Expo from 'expo-server-sdk';

instead of

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM