dougmoscrop / serverless-plugin-include-dependencies

MIT License
184 stars 41 forks source link

"Cannot find modules" when compiling a TypeScript project #30

Open mushketyk opened 5 years ago

mushketyk commented 5 years ago

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",
dsmileym4 commented 5 years ago

We are experiencing this same issue.

dougmoscrop commented 5 years ago

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?

yzpaul commented 4 years ago

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 /.build

HarshUpparwal commented 2 years ago

any workaround this plugin?

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

env-poehler commented 2 years ago

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

denis-ryzhkov commented 2 years ago

@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.

nick-verida commented 1 year ago

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

jeison-od commented 5 months ago

@denis-ryzhkov I can confirm it too!

brayoh commented 2 months ago

Experiencing a similar issue, any updates on this?