Expo server + webpack does not seem to work for AWS Lambda

Hey everybody,
I have an issue with webpack and the xpo notifications sdk.
Here is what I use:
SDK Version: expo-server-sdk-node @latest 3.6.0
Platforms(web AWS LAMBDA):
My webpack config is:

// webpack.config.js
const path = require('path');
const webpack = require('webpack');
module.exports = {
  target: 'node',
  plugins: [
    new webpack.IgnorePlugin({ resourceRegExp: /^pg-native$/})
  module: {
    rules: [
        loader: 'ts-loader',
        options: {
        transpileOnly: true
  resolve: {
    extensions: ['.ts', '.js']
  output: {
    libraryTarget: 'commonjs',
    path: path.join(__dirname, '.webpack'),
    devtoolModuleFilenameTemplate: info => {
      return `webpack:///${info.resourcePath}`;
    //filename: '[resource-path].js'
  mode: 'development',
  externals: {
    googleapis: "commonjs googleapis",
    "aws-sdk": "aws-sdk",
    "expo-server-sdk": "commonjs expo-server-sdk"

My tsconfig is:

  "compilerOptions": {
    "preserveConstEnums": true,
    "strictNullChecks": true,
    "sourceMap": true,
    "experimentalDecorators": true,
    "target": "es2017",
    "module": "commonjs",
    "lib": [
  "exclude": [

However, when I hit my lambda I get:

ERROR	Error: Cannot find module 'expo-server-sdk'
Require stack:
- /var/task/notifications/notifications.js
- /var/task/s_checkNotifications.js
- /var/runtime/UserFunction.js
- /var/runtime/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Module._require.o.require (/var/task/serverless_sdk/index.js:9:72934)
    at require (internal/modules/cjs/helpers.js:74:18)
    at eval (webpack:///external_%22expo-server-sdk%22:1:18)
    at Object.expo-server-sdk (/var/task/notifications/notifications.js:984:1)
    at __webpack_require__ (/var/task/notifications/notifications.js:1106:42)
    at eval (webpack:///./notifications/notifications.ts:4:27)
    at Object../notifications/notifications.ts (/var/task/notifications/notifications.js:896:1)
    at __webpack_require__ (/var/task/notifications/notifications.js:1106:42)
    at /var/task/notifications/notifications.js:1116:18 {
  requireStack: [

and if I opt out of putting that module as an externals, I get this:

ERROR in ./node_modules/expo-server-sdk/package.json
Module build failed (from ./node_modules/ts-loader/index.js):
Error: Debug Failure. Output generation failed
    at Object.transpileModule (C:\Users\sg\Desktop\CODE\sc-server\node_modules\typescript\lib\typescript.js:123670:29)
    at getTranspilationEmit (C:\Users\sg\Desktop\CODE\sc-server\node_modules\ts-loader\dist\index.js:390:75)
    at successLoader (C:\Users\sg\Desktop\CODE\sc-server\node_modules\ts-loader\dist\index.js:38:11)
    at Object.loader (C:\Users\sg\Desktop\CODE\sc-server\node_modules\ts-loader\dist\index.js:23:5)
 @ ./node_modules/expo-server-sdk/build/ExpoClient.js 176:31-65
 @ ./notifications/notifications.ts 4:26-52
webpack compiled with 1 error in 5422 ms
  Error --------------------------------------------------
  Error: Webpack compilation error, see above

Any ideas, cuz I think I am stuck :<<<<<<<<<<<<<<<

Turned out I needed to exclude the node_modules. Solved it. Thanks to everyone who looked into this. Happy coding! :))))))))

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.