I'm trying to use webpack in a truffle project. I follow this guide https://github.com/ConsenSys/truffle/wiki/Using-Truffle-and-Webpack-(beta).

At point 8 in my app.js I add this line:

var TestRPC = require("ethereumjs-testrpc");
  if (typeof web3 !== 'undefined') {
  web3 = new Web3(web3.currentProvider);
} else {
 web3 = new Web3(new web3.setProvider(TestRPC.provider()));

Unfortunately when i require ethereumjs-testrpc the Chrome console output: Uncaught Error: Cannot find module "fs".

I try to add in my webpack config: node: { console: true, fs: 'empty', net: 'empty', tls: 'empty' }

with no success.

Tks for help.


As far as My understanding goes ,ethereumjs-testrpc is a node module and the way you want to test your code is through node.js. And I believe, You are trying execute the javascript which meant to be running in the node.js environment, which is why you mentioned chrome browser. fs module means file system module which is generally used in node.js environments to access the file system.Some modules like fs in node are not compatible with chrome ( browsers), they are meant to be running in servers ( node.js)

  • What you said about fs is right but, in truffle with default build , testrpc are served by the truffle build not from node . So I do not think is a node problem. In the guide they don't mention node.
    – underdog
    Jul 2 '16 at 21:59
  • truffle is a module in node. That is why we do "npm install truffle -g" is not it ? Jul 2 '16 at 22:05
  • Yes but I think is a webpack problem, It can't serve TestRpc in right way. I don't know. No response by ConsenSys. Truffle serve command pull up a node that serve all dependencies. Rigth?
    – underdog
    Jul 2 '16 at 22:12

Not from Consensys Truffle but a good boilerplate for truffle + webpack. https://github.com/niran/dapp-boilerplate

  • 1
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Afr
    Jul 12 '16 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.