CoorpAcademy / serverless-plugins

Collection of serverless plugins :zap:
230 stars 131 forks source link

[serverless-offline-dynamodb-streams] Error: Cannot find module 'serverless-offline/lambda' #238

Open amartini93 opened 1 year ago

amartini93 commented 1 year ago

I'm getting this error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/serverless-offline/lambda' imported from /serverless-offline-dynamodb-streams/src/index.js

Indeed in node_modules in the serverless-offline directory there's no lambda. Do I need to npm install a specific version?

My npm -v is 6.14.17 and "dependencies": { "add": "^2.0.6", "serverless": "^2.46.0", "serverless-domain-manager": "^6.0.2", "serverless-offline-dynamodb-streams": "^6.2.3", "serverless-pseudo-parameters": "^2.5.0", "serverless-python-requirements": "^5.2.2" }, "devDependencies": { "serverless-dynamodb-local": "^0.2.40", "serverless-offline": "^8.8.0", "serverless-offline-aws-eventbridge": "^1.6.6", "serverless-puresec-cli": "^1.2.1", "serverless-s3-local": "^0.6.18" }

Also I would like to add a different problem I saw in a closed issue that was closed without solving and asked to reopen, but never did. Is about using tableName: myTable in the function config.

Serverless: Configuration warning: Serverless: at 'functions['myfunction'].events[0].stream': unrecognized property 'tableName'

amartini93 commented 1 year ago

I think I might have fixed it replacing line 107 of node_modules/serverless-offline-dynamodb-streams/src/index.js from: const {default: Lambda} = await import('serverless-offline/lambda');

to: const Lambda = require("serverless-offline/dist/lambda").default;

But maybe someone should take a look at it anyway.

andy-little commented 1 year ago

+1 I get almost the same error: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lambda' is not defined by "exports" in /node_modules/serverless-offline/package.json imported from /node_modules/serverless-offline-sqs/src/index.js But @amartini93's suggestion does not work for me.

pianomansam commented 1 year ago

This isn't enforced, but I believe you need to have Serverless Offline >= 10 for the latest releases of this