Skip to content

Error when adding a module dependency #2

@tom-thorne

Description

@tom-thorne

The template works out of the box. However, as soon as you yarn add any dependency and use it in your code, you get a runtime error (se below).

This is solved by removing the package block in the serverless.yml file, which was excluding node_modules from the package.

I am not clear what the intention is here - should node_modules be excluded and some other setting or plugin is missing?

Unable to import module ‘handler’: Error
   at Function.Module._resolveFilename (module.js:547:15)
   at Function.Module._load (module.js:474:25)
   at Module.require (module.js:596:17)
   at require (internal/module.js:11:18)
   at Object.<anonymous> (/var/task/handler.js:3:16)
   at Module._compile (module.js:652:30)
   at Object.Module._extensions..js (module.js:663:10)
   at Module.load (module.js:565:32)
   at tryModuleLoad (module.js:505:12)
   at Function.Module._load (module.js:497:3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions