serverless-plugin-include-dependencies icon indicating copy to clipboard operation
serverless-plugin-include-dependencies copied to clipboard

"Cannot find modules" when compiling a TypeScript project

Open mushketyk opened this issue 7 years ago • 9 comments

When I try to deploy a serverless project with the serverless-plugin-include-dependencies plugin I get the following error:

Cannot find module '.../src/function'

With the following stacktrace:

Error: Cannot find module '.../src/function'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:587:15)
    at Function.resolve (internal/modules/cjs/helpers.js:32:19)
    at IncludeDependencies.getHandlerFilename (.../node_modules/serverless-plugin-include-dependencies/include-dependencies.js:134:20)

I think the bug is that it is looking for a file src/function (that does not exist), while the file it should be looking for is src/function.ts that exists.

Here is my configuration:

plugins:
  - serverless-webpack
  - serverless-reqvalidator-plugin
  - serverless-aws-documentation
  - serverless-plugin-canary-deployments
  - serverless-dynamodb-local
  - serverless-offline
  - serverless-plugin-include-dependencies

package:
  individually: true

Here is the version of the plugin that I use:

"serverless-plugin-include-dependencies": "^3.2.1",

mushketyk avatar May 07 '19 19:05 mushketyk

We are experiencing this same issue.

dsmileym4 avatar May 07 '19 20:05 dsmileym4

I don't use TypeScript unfortunately! I'm open to PRs of course.

Don't you have to compile your .ts files in to .js files? Are those not referenced by serverless.yml or does it support TS directly?

dougmoscrop avatar May 07 '19 20:05 dougmoscrop

I don't use TypeScript unfortunately! I'm open to PRs of course.

Don't you have to compile your .ts files in to .js files? Are those not referenced by serverless.yml or does it support TS directly?

Serverless compiles TS into JS in <PROJ_ROOT>/.build

yzpaul avatar May 20 '20 17:05 yzpaul

any workaround this plugin?

Inspite of having file at said path, error msg pops up saying Cannot find module

HarshUpparwal avatar Jun 15 '22 19:06 HarshUpparwal

I was also having this issue. However, I managed to get it working by installing the npm package 'serverless-plugin-typescript'

env-poehler avatar Jun 27 '22 14:06 env-poehler

@env-poehler, do you have both serverless-plugin-include-dependencies and serverless-plugin-typescript in serverless.yml and both are working? I had to delete serverless-plugin-include-dependencies to make it work.

denis-ryzhkov avatar Oct 11 '22 19:10 denis-ryzhkov

I can confirm removing serverless-plugin-include-dependencies helped with this.

nick-verida avatar Dec 28 '22 01:12 nick-verida

@denis-ryzhkov I can confirm it too!

jeison-od avatar Jun 22 '24 00:06 jeison-od

Experiencing a similar issue, any updates on this?

brayoh avatar Sep 23 '24 07:09 brayoh