Working fine offline, failing in aws lambda

aws

#1

Hello.

I want to make an AWS lambda using serverless framework.

In my project, I use the web3 node module.
This is how I import it:
const Web3 = require('web3');

And I mostly use it this way:
var web3 = new Web3(new Web3.providers.HttpProvider('http://<IP_VALUE>:<PORT_VALUE>'));

When running this with sls offline, everything works fine and as expected. However, when uploading to lambda using sls deploy, I get the following error:

TypeError: Cannot read property 'HttpProvider' of undefined
    at getNode (/var/task/web3.js:62:43)

Any clue of what is doing that, why and how I can solve this?


#2

Have you found a solution to this? I too am encountering the same problem in Firebase Cloud Functions.