Expo: TypeError: Expo is not a constructor (expo-server-sdk-node)

Created on 6 Sep 2018  路  1Comment  路  Source: expo/expo

Environment

expo-server-sdk-node

Steps to Reproduce

(Write your steps here:)

  1. const Expo = require('expo-server-sdk')
  2. let expo = new Expo();
  3. Error: TypeError: Expo is not a constructor

Expected Behavior

It should create a new instance of Expo

(Write what you thought would happen.)

Actual Behavior

When I use version ^2.3, it works like a charm. However, when I upgraded to version 3, it stopped working.

It throws an error: TypeError: Expo is not a constructor.

My guess is you guys changed some methods but the documentation doesn't anything on what has to be done to upgrade.

Most helpful comment

The release notes explain this explicitly in the Breaking Changes section: https://github.com/expo/expo-server-sdk-node/releases/tag/v3.0.0

JavaScript Modules: CommonJS-style require() calls, as opposed to JavaScript import statements, must now explicitly import either the default export or the named Expo export. Any of these work:
const { Expo } = require('expo-server-sdk');
const { default: Expo } = require('expo-server-sdk');
import Expo from 'expo-server-sdk';
import { Expo } from 'expo-server-sdk';
Does not work: const Expo = require('expo-server-sdk');

>All comments

The release notes explain this explicitly in the Breaking Changes section: https://github.com/expo/expo-server-sdk-node/releases/tag/v3.0.0

JavaScript Modules: CommonJS-style require() calls, as opposed to JavaScript import statements, must now explicitly import either the default export or the named Expo export. Any of these work:
const { Expo } = require('expo-server-sdk');
const { default: Expo } = require('expo-server-sdk');
import Expo from 'expo-server-sdk';
import { Expo } from 'expo-server-sdk';
Does not work: const Expo = require('expo-server-sdk');
Was this page helpful?
0 / 5 - 0 ratings