question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use/bundle the web3 package correctly?

See original GitHub issue

This is a Bug Report

Description

For bug reports:

  • What went wrong? Stuck on packaging after running serverless webpack for a very long time > 10 minutes.
  • What did you expect should have happened? Packaged sooner than that.
  • What was the config you used?
// webpack.config.js

var path = require('path')
const slsw = require('serverless-webpack')
var nodeExternals = require('webpack-node-externals')

var entries = slsw.lib.entries

const models = [
  './models/charge.model.js',
  './models/metrics.model.js',
  './models/user.model.js'
]
for (let i in models) {
  entries[models[i]] = models[i]
}

module.exports = {
  entry: entries,
  target: 'node',
  // Generate sourcemaps for proper error messages
  devtool: 'eval',
  // Since 'aws-sdk' is not compatible with webpack,
  // we exclude all node dependencies
  externals: [nodeExternals()],
  // Run babel on all .js files and skip those in node_modules
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: __dirname,
        exclude: /node_modules/
      }
    ]
  },
  output: {
    libraryTarget: 'commonjs',
    path: path.join(__dirname, '.webpack'),
    filename: '[name].js'
  }
}
  • What stacktrace or error message from your provider did you see? This is the message it is stuck on: Serverless: Packing external modules: babel-runtime@^6.25.0, sequelize@^4.8.3, nodemailer@^4.0.1, hat@0.0.3, promise@^8.0.1, web3@^1.0.0-beta.18, truffle-contract@^3.0.0, basic-auth@^2.0.0

  • Serverless-Webpack Version you’re using: 3.0.0

  • Webpack version you’re using: 3.5.6

  • Serverless Framework Version you’re using: 1.22.0

  • Operating System: macOS 10.12.6

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:52 (25 by maintainers)

github_iconTop GitHub Comments

1reaction
rhlsthrmcommented, Sep 21, 2017

Contents of nodeModules:

[ '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/node_modules/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-bzz/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-core/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-core-helpers/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-core-method/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-core-promiEvent/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-core-requestManager/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-core-subscriptions/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-eth/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-eth-abi/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-eth-accounts/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-eth-contract/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-eth-iban/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-eth-personal/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-net/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-providers-http/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-providers-ipc/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-providers-ws/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-shh/node_modules',
  '/Users/Rahul/Desktop/connext/ConnextAPI/src/server/node_modules/web3/packages/web3-utils/node_modules' ]

Looks like the right stuff is in there. I’ll try with the latest PR. I might not get to it today, but I’ll update when I find out more.

1reaction
HyperBraincommented, Sep 21, 2017

Verification is quite easy: Run serverless package and check the zip files created in .serverless if they contain the modules.

For the config … I’ll try to come up with a solution after reading the thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

web3js later versions. Bundle, how? - Ethereum Stack Exchange
I'm trying to build the frontend of a dApp, but the web3js makes my head hurt. I need to include it in my...
Read more >
Getting Started — web3.js 1.0.0 documentation
The web3.js library is a collection of modules that contain functionality for the ethereum ... web3-eth is for the ethereum blockchain and smart...
Read more >
very fast airplane crossword clue
I am trying to use the pinyin package for glossing Chinese text. ... The clue can narrow your options down to the correct...
Read more >
Using the Ethereum Web3 Library to Send Transactions on ...
The Web3 JavaScript library is one of the many ways we can interact with ... installed correctly by querying the version for each...
Read more >
Set up web3.js to use the Ethereum blockchain in JavaScript
To test that we correctly configured our Web3 instance, we'll try to retrieve the latest block number using the getBlockNumber function.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found