TypeError: Cannot convert undefined or null to object when deploying to testnet
See original GitHub issue- I’ve asked for help in the Truffle Gitter before filing this issue.
Issue
I keep getting an error when trying to run truffle migrate.
Steps to Reproduce
Create a project directory called my-project Ensure truffle is installed Type in “truffle init” in the terminal while in the my-project directory cd contracts git clone https://github.com/OpenZeppelin/openzeppelin-solidity.git Create a file called Example.sol Paste the following code into the Example.sol file.
pragma solidity ^0.5.0;
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";
contract ExampleToken is ERC20, ERC20Detailed {
uint private INITIAL_SUPPLY = 10000e18;
constructor () public
ERC20Detailed("ExampleToken", "EGT", 18)
{
_mint(msg.sender, INITIAL_SUPPLY);
}
}
cd … # To get into the parent directory create a file called secrets.json and paste the following into it { “mnemonic”: “x x x x x x x x x x x x” } Ensure that the mnemonic matches the mnemonic from the local instance of geth.
npm init npm install --save web3 npm install --save truffle-hdwallet-provider modify truffle.js to match the following…
var secrets = require("./secrets.json");
var HDWalletProvider = require("truffle-hdwallet-provider");
var Web3 = require('web3'); // Set variable to the web3 module
var web3 = new Web3(Web3.givenProvider || "ws://localhost:8545");
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*", // Match any network id
gas: 10000000,
gasLimit: 26000000000
},
ropsten: {
provider: new HDWalletProvider(secrets.mnemonic, "https://ropsten.infura.io/"),
network_id: "*",
gas: 1000000,
gasLimit: 67000000,
gasPrice: 20000000000
},
// network_id: 3,
// host: "localhost",
// port: 8545,
// gas: 2900000
mainnet: {
provider: new HDWalletProvider(secrets.mnemonic, "https://mainnet.infura.io/"),
network_id: 1,
gas: 1000000,
gasLimit: 67000000
}
},
compilers: {
solc: {
version: "0.5.2"
}
}
};
In 1_initial_migration.js file in migrations folder:
module.exports = function(deployer) {
};
In 2_deploy_contracts.js file remove all the code:
module.exports = function(deployer) {
};
type in truffle migrate --network ropsten into terminal
Expected Behavior
For no contracts to be deployed, but for no errors to be thrown either.
Actual Results
I get the following message in terminal: TypeError: Cannot convert undefined or null to object at Function.keys (<anonymous>) at supplier.load.then.solc (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/index.js:184:1) at <anonymous> Truffle v5.0.5 (core: 5.0.5) Node v8.11.1
Environment
- Operating System: Version 10.14.2
- Ethereum client: Version: 1.8.5-unstable
- Truffle version (
truffle version): Truffle v5.0.5 (core: 5.0.5) - node version (
node --version): Node v8.11.1 - npm version (
npm --version): 5.6.0
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (7 by maintainers)

Top Related StackOverflow Question
Closing this again for issue maintenance; if anyone is still having this issue, I would suggest opening a new one. Thanks!
I followed the steps listed in this bug report and what I found was that the migration worked when I reproduced the problem. When creating the report I had to create an environment that matched my proprietary codebase, but the new environment gives different results.