I have working truffle app that interacts with Ropsten Testnet but currently, I'm on my local machine environment at localhost:3000.

I want to deploy this app to heroku such that my ropsten testnet stills works as expected. I tried googling a lot and also tired some of the stuffs but nothing came around that could to solve my problem.

Here is my truffle.js file:

var HDWalletProvider = require("truffle-hdwallet-provider");

var infura_apikey = "my api key";
var mnemonic = "some awesome mneumonic";

module.exports = {
    networks: {
        development: {
            host: "localhost",
            port: 8545,
            network_id: "*" // Match any network id
        ropsten: {
            provider: new HDWalletProvider(mnemonic, 
                      "https://ropsten.infura.io/" + infura_apikey),
            network_id: 3,
            gas: 400000

And, here is my package.json file:

    "name": "decentralizedtodo",
    "version": "1.0.0",
    "description": "",
    "main": "truffle.js",
    "directories": {
        "test": "test"
    "scripts": {
        "dev": "lite-server",
        "test": "echo \"Error: no test specified\" && exit 1"
    "author": "Pramesh Bajrachaarya",
    "license": "ISC",
    "devDependencies": {
        "lite-server": "^2.3.0"
    "dependencies": {}

This may be a noob question but, can someone please give a stepwise answer to the very process?

This will be helpful to me as well as future readers too.

  • my package.json is this, do i have to change anything to deploy to heroku? `{ "name": "truffle-init-webpack", "version": "0.0.2", "description": "Frontend example using truffle v3", "scripts": { "lint": "eslint ./", "build": "webpack", "dev": "webpack-dev-server" }, "author": "Douglas von Kohorn", "license": "MIT", "devDependencies": { "babel-cli": "^6.22.2", "babel-core": "^6.22.1", "babel-eslint": "^6.1.2", "babel-loader": "^6.2.10", "babel-plugin-transform-runtime": "^6.22.0", "babel-preset-env": "^1.1.8", "babel-preset-es2015": "^6.22.0", "babel-register": "^6.22.0", "copy-webpack-plugin": Apr 11 '18 at 15:47
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review
    – ivicaa
    Apr 11 '18 at 19:58

I've done it!

You need change your package.json

"start": "npm run test",
"dev": "lite-server",
"test": "lite-server"

And add a file bs-config.js with this code:

module.exports = {
  port: process.env.PORT,
  files: ['.src/**/*.{html,htm,css,js}'],
    baseDir: ["./src", "./build/contracts"]

Good luck!

repo: https://github.com/bukosabino/truffle-voting-dapp-ropsten

url dapp: https://voting-dapp-ropsten.herokuapp.com

  • Thanks, I ended up writing a small node server to serve my static files. This might work. Will try as soon as possible 🙂 Mar 20 '18 at 3:02

Its going to be just another deployment like nodejs application. But just remember change the network in truffle.js to mainnet or ropsten or rinkeby. And also run truffle migrate on that network.

You could use THIS LINK or THIS for reference.

  • Yea, I have already changed the network in truffle.js and truffle migrate --network ropsten. Going to deploy it as a node app real soon. Have you tried this before? Feb 7 '18 at 13:01

I just found out that the thing I'm trying to do cannot be done in Heroku.


It's due to heroku ephemeral filesystem.

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.