Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.
This repository was archived by the owner on May 17, 2021. It is now read-only.

Module not found #1

Description

@OmarKhattab

I followed this to the T, I have a feeling serverless-webpack is messing it up. When i look in the transpiled code I see that the module is not found const test = webpack_require(!(function webpackMissingModule() { var e = new Error("Cannot find module 'test'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));

import { success, failure } from "./libs/response-lib";
export const hello = async (event, context) => {
  const fs = require('fs').promises;

  try {
    const test = require('test');
    test();
    return success({ status: 'ok' })
  }
  catch(error) {
    console.log(error)
    return failure({ message: error.message })
  }
};

Screen Shot 2019-12-25 at 7 21 21 PM
Screen Shot 2019-12-25 at 7 22 10 PM

# NOTE: update this with your service name
service: api

# Create an optimized package for our functions
package:
  individually: true
  exclude:
    - schema-layer/**

plugins:
  - serverless-bundle # Package our functions with Webpack
  - serverless-offline
  - serverless-dotenv-plugin # Load .env as environment variables

provider:
  name: aws
  runtime: nodejs10.x
  stage: dev
  region: us-east-1
  # To load environment variables externally
  # rename env.example to .env and uncomment
  # the following line. Also, make sure to not
  # commit your .env.
  #
  #environment:
  #  sampleEnvVar: ${env:SAMPLE_ENV_VAR}

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: hello
          method: get
    layers:
      - { Ref: SchemalayerLambdaLayer }

layers:
  schemalayer:
    path: schema-layer

custom:
  bundle:
    linting: false # disable linting as a part of the build process

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions