'Error: TodoList has not been deployed to detected network (network/artifact mismatch)

truffle(development)> TodoList = await TodoList.deployed() Uncaught: Error: TodoList has not been deployed to detected network (network/artifact mismatch) at processTicksAndRejections (node:internal/process/task_queues:96:5) at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-contract/lib/contract/constructorMethods.js:113:1



Solution 1:[1]

Please follow the steps:
  1. Create another file named 2_anyname.js(make sure it doesn't start with 1 and you can name it anything) in migration folder.

  2. Paste this content in file

    var contract_name = artifacts.require('contract_name');
    
    module.exports = function (deployer) {  
    deployer.deploy(contract_name); };
    
  3. run commands in this order : truffle compile -> truffle migrate --reset or truffle deploy --reset -> truffle console

  4. you are good to go !!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jazz