question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reference Error - not defined (develop console)

See original GitHub issue
  • I’ve asked for help in the Truffle Gitter before filing this issue.
truffle(development)> Election.deployed().then(function(instance) { app = instance })
ReferenceError: Election is not defined
truffle(development)> app.address
ReferenceError: app is not defined

Not sure why I’m receiving reference errors. No one replied on Gitter, and a Google search offered no solutions.

Environment

  • Operating System: Windows 10
  • Truffle version (truffle version): 4.1.8

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
cgeweckecommented, May 12, 2018

@ArranMcC To use deployed you’ll need to run migrate first. This deploys your contracts to the test chain managed by the develop shell. The metacoin box is a working example you might find helpful, and check out the migrations documentation for help on writing deployment scripts:

$ mkdir metacoin
$ cd metacoin
$ truffle unbox metacoin
$ truffle develop

# ..... client launches ....

truffle(develop)> MetaCoin.deployed()
ReferenceError: MetaCoin is not defined . # <--- Your error
truffle(develop)> migrate                 # <--- Run `migrate` 
Compiling ./contracts/ConvertLib.sol...
Compiling ./contracts/MetaCoin.sol...
Compiling ./contracts/Migrations.sol...

# .... etc ....

Writing artifacts to ./build/contracts

Using network 'develop'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x4cb1916eb9734e8622d8e49a9a1a96c8338f8065f9ccee3963ff9dbc67fc8ae0
  Migrations: 0x8cdaf0cd259887258bc13a92c0a6da92698644c0
Saving successful migration to network...
  ... 0xd7bc86d31bee32fa3988f1c1eabce403a1b5d570340a3a9cdba53a472ee8c956

# ..... etc .....

truffle(develop)> MetaCoin.deployed()
TruffleContract {
  constructor: 
   { [Function: TruffleContract]
     _static_methods: 
      { setProvider: [Function: setProvider],   
2reactions
ArranMcCcommented, May 23, 2018

Thanks! I think it was just due to truffle not being unboxed into an empty directory, something which the tutorials I was following didn’t mention as they maybe thought it was obvious.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: "x" is not defined - JavaScript - MDN Web Docs
ReferenceError : "x" is not defined. The JavaScript exception "variable is not defined" occurs when there is a non-existent variable referenced somewhere.
Read more >
What does the error (ReferenceError: Console is not defined ...
In general, a reference error means that you used a word that JavaScript didn't recognize. It's neither a pre-existing part of the JavaScript...
Read more >
Console error "Uncaught ReferenceError: $ is not defined"
This error means your jQuery file has not been loaded. Based on your code, you have to remove one of the script tags...
Read more >
ReferenceError: "x" is not defined - Javascript
There is a non-existent variable referenced somewhere. This variable needs to be declared, or you need make sure it is available in your...
Read more >
Getting the "img not defined" reference error in the console
Getting the "img not defined" reference error in the console · it loads a random image · it loads a list of breeds...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found