Environment
Visual Studio with juanblanco.solidity extension
Truffle v5.1.66 (core: 5.1.66)
Node v14.15.0
Using the latest openzeppelin contract available at “npm install @openzeppelin/contracts”
Details
I am trying to use ERC20 to mint token however I am getting the stated error when I am trying to migrate
TypeError: Cannot read property ‘imports’ of undefined at Object. (C:\Users\dsi user\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\compile-common\dist\src\profiler\requiredSources.js:98:1)
at Generator.next ()
at fulfilled (C:\Users\dsi-user\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\compile-common\dist\src\profiler\requiredSources.js:5:42)
Code to reproduce
MyToken.sol
pragma solidity ^0.7.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor(uint256 initialSupply) ERC20("Gold", "GLD") {
_mint(msg.sender, initialSupply);
}
}
For migration the code is
var MyToken = artifacts.require("MyToken.sol");
module.exports = async function (deployer) {
await deployer.deploy(MyToken,1000000);
};