ReferenceError and Syntax Error on migrate command to Truffle

  • JavaScript
  • Thread starter zak100
  • Start date
  • Tags
    Error
In summary, the conversation is about a person who is following a tutorial on debugging and variable inspection provided on a website for Truffle. They are trying to execute the "migrate" command on Truffle, but it gives a Reference Error and Syntax Error. The person also mentions using a different folder for Fibonacci and starting the testrpc. They also share their code for Fibonacci.sol, 2_deploy_contracts.js, and truffle.js. They ask for guidance on how to proceed with the tutorial.
  • #1
zak100
462
11
Hi,

I am following the description provided on the web page:https://truffleframework.com/tutorials/debugger-variable-inspection

I am trying to execute the “migrate” command on the truffle. It says Reference Error and also gives syntax error:
truffle(development)> migrate

Using network 'development'.Running migration: 1_initial_migration.js

Deploying Migrations...

... 0xe37cab98f7bf2521ea31290f8cd831ec68a8a4a2f534bc7008da64daa28fecf3

Migrations: 0xee9e0e26e6542949d3c32ef2ef8041c68d5bacd8

Saving successful migration to network...

... 0x46e510bfa2fcd87c45c286ae843ed524699988cf8ea882cff7f702a1ccae9564

Saving artifacts...

Running migration: 2_deploy_contracts.js

Deploying Fibonacci...

... 0x37ff19549fb84e23a323e5551393111e8d4164259612c1b989450b2c72ca1417

Fibonacci: 0x062f46a381166602baa7692a1686b7fb0b2ff7e2

Saving successful migration to network...

... 0x13bdf5882017d6284928bd4462d365f0330580536e56576d667423dd512ddedf

Saving artifacts...

truffle(development)> truffle(development)> migrate

ReferenceError: truffle is not defined

truffle(development)> Using network 'development'.

evalmachine.<anonymous>:1

Using network 'development'.

^^^^^^^SyntaxError: Unexpected identifier

at new Script (vm.js:79:7)

at createScript (vm.js:251:10)

at Object.runInContext (vm.js:284:10)

at Console.interpret (C:\Users\HP\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:94589:17)

at ReplManager.interpret (C:\Users\HP\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:95306:18)

at bound (domain.js:396:14)

Instead of Fibonacci folder, I am using Fibonacci2 folder and also started the testrpc:
C:\fibonacci2>testrpc

EthereumJS TestRPC v6.0.3 (ganache-core: 2.0.2)Available Accounts

==================

(0) 0x82d42d57840cc95af8df42283c769762636166fc

(1) 0x219c27130b7ab0506b5b2bc56bd376dba2a7ad62

(2) 0xfa9cbe3c1aff9b593c06aa1de789a5cb0af21067

(3) 0x4d3ce98d30f9cfccae1b9558d6aa11317c088d2f

(4) 0xd3e3a390064b73c1e4f9efc1eb214dff61b4f66a

(5) 0xaaa46c09aa132991ed2b9457db8ecbbcb914be83

(6) 0x8fda0092c64e471a4ef5f6ef4a6574a23dd91008

(7) 0xcdc51105bb0743b91507a1a6b492388c5599434a

(8) 0x5562888497e42df6242d23d8f00d3bbbc9c0726e

(9) 0xd60db2ee1d69652ea432044f1c1a9a2eb8864023Private Keys

==================

(0) 94090e3f5d1ef0abadc74062bc5323c948acb77fdcfd8d36622f00173a0bf6ff

(1) 384d6979f81ea7f36d9b5c81ba0b78d1a082397d9f2a7805a3f947bf70601e5f

(2) b2782583fa6594b27645e3893eb20c733ba085dee229153fa2cd43a944d3b849

(3) f9db43b60dba6be6609626373de252503720379a0cb2ecea4e34613c917f44d3

(4) 9676febc9db2431aa99a7d154cdd4e6c405a02ca92c569885ad060c4f8cb31f5

(5) e18fadebc5115d2d37f63cb140b556c1efd4e45c5c1807f77f82c5fc924d82a9

(6) df4be421d627e4f0ce9b8c66917cdb9c74d1dfcd7973c2af0c03ee9fece271ff

>

C:\fibonacci2>817ed400029d4eff48930f5aa3816a1289dbccdc89bbac9173083c

C:\fibonacci2>b9bfc90bbc8ca0b61af95c9ff088ecd13f0f9c66c9725a9a159f26

C:\fibonacci2>

C:\fibonacci2>

C:\fibonacci2>====

C:\fibonacci2> leader velvet infant hidden garbage bomb deny hotel shoe first call afraid

C:\fibonacci2> m/44'/60'/0'/0/{account_index}

C:\fibonacci2>

C:\fibonacci2>ocalhost:8545

C:\fibonacci2>

C:\fibonacci2>

C:\fibonacci2>

C:\fibonacci2>testrpc&

EthereumJS TestRPC v6.0.3 (ganache-core: 2.0.2)Available Accounts

==================

(0) 0x94450db0f5db670eaab74a4135f385a1f6106dd1

(1) 0x8c7194542ce7229f97da968a6ef833e98f8700bb

(2) 0x9b94eb78b82daddd1b6f747d2d78283f25f9ab34

(3) 0x853f332b0aa1a8e94d31095dcfc3ee262d9f2207

(4) 0x6c9d74e375133457ac4d9644f91e50b738b9911d

(5) 0x52702ea7a7d6a4319907988dc048e35f9f8a79ea

(6) 0x178324d7cf2d40799c4d25198132abd3e7fe4712

(7) 0x8b3bb3a623b7d4834a09e5320402bd8977245f31

(8) 0x0abd10b80aede580f0b1b0798b702065bd7a2234

(9) 0xeffdc27074432b8786c3d6619f5e9f39e3a0e5a8Private Keys

==================

(0) 37a1be74ef71565f3a9a87111ab30d76dad58460452ac2e86404261f3b7e5dd8

(1) 82d00ce49b75a483c6f2bb3a7e193ee732cc13970f63aae94ee426e16d2f0ede

(2) d3506377dd206b85704a7353c2a59036f698b306fd5f785c8b9cfae6e3b7bae7

(3) 1cc67aae40c5d7e8b6105722ed1650f005bce98c78b4dce66c5ff363b7021ff8

(4) f5669041a807aeb0923d554c88a8f883657bb8f858b1121cf21bcd1cf47aa15d

(5) 5f1e72f8ab7901860f86ee1c297b84efffaf11d0be26ff61135719095db8b5fb

(6) a73672115472d59f609bd682e49e5fdfe03fa52f77b7add300d81825d54ea6cf

(7) 53064980cb9542989997d721468a7d389bcdd13f9f45f3ae699027bd989c6b09

(8) 541719b338de156257f4aba44ca2418410f1b69a40c9b43042f791ab5fe29a4e

(9) 320fa70e20ca755c1d751fbbcef33123cde204fc1e898e88a318db5c30c5d420HD Wallet

==================

Mnemonic: resemble stage lesson eight outdoor kingdom flag include curtain unit relax aunt

Base HD Path: m/44'/60'/0'/0/{account_index}Listening on localhost:8545

>
==
My code details are: Fibonacci.sol (solidity code)
Code:
pragma solidity ^0.4.22;contract Fibonacci {uint[] fibseries;  // n = how many in the series to return

  function generateFib(uint n) public {    // set 1st and 2nd entries

    fibseries.push(1);

    fibseries.push(1);    // generate subsequent entries

    for (uint i=2; i < n ; i++) {

      fibseries.push(fibseries[i-1] + fibseries[i-2]);

    }  }}

==2_deploy_contracts.js
JavaScript:
var Fibonacci = artifacts.require("Fibonacci");module.exports = function(deployer) {

  deployer.deploy(Fibonacci);

};

==truffle.js

JavaScript:
/*

* NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a

* function when declaring them. Failure to do so will cause commands to hang. ex:

* ```

* mainnet: {

*     provider: function() {

*       return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/<infura-key>')

*     },

*     network_id: '1',

*     gas: 4500000,

*     gasPrice: 10000000000,

*   },

*/module.exports = {

  // See <http://truffleframework.com/docs/advanced/configuration>

  // to customize your Truffle configuration!

};module.exports = {

  networks: {

    development: {

      host: "127.0.0.1",

      port: 7545,

      network_id: "*"

    }

  }

};

Some body please guide m.

Zulfi.
 
Technology news on Phys.org
  • #2
Since you’re doing a tutorial, try starting from the beginning again and do each step exactly as given. Be as meticulous as possible. The site must have a forum where you can ask questions. We at PF just aren’t familiar with these arcane software frameworks.
 
  • #3
Thanks.

Zulfi.
 

1. What is a ReferenceError and how does it occur?

A ReferenceError is an error that occurs when a variable or function is referenced, but it is not defined or declared. This can happen if the variable or function name is misspelled, or if it is not declared in the current scope.

2. What is a SyntaxError and why does it occur?

A SyntaxError is an error that occurs when the code is not written in the correct syntax. This can happen if there are missing or extra characters, incorrect use of punctuation, or incorrect placement of keywords or symbols.

3. How do I troubleshoot a ReferenceError or SyntaxError on the migrate command in Truffle?

To troubleshoot these errors, you can start by checking your code for any spelling or syntax errors. Make sure all variables and functions are properly declared and used. You can also consult Truffle's documentation or seek help from the community for specific issues related to the migrate command.

4. Can a ReferenceError or SyntaxError on the migrate command be caused by external factors?

Yes, these errors can also be caused by external factors such as outdated dependencies or conflicts between different versions of packages. It is important to keep your dependencies up to date and to check for any compatibility issues.

5. How can I prevent ReferenceError and SyntaxError on the migrate command in Truffle?

To prevent these errors, it is important to follow best practices for coding, such as properly declaring and using variables and functions, and regularly checking for spelling and syntax errors. It is also important to stay updated on any changes or updates in Truffle or related packages that may affect your code.

Similar threads

  • Programming and Computer Science
Replies
2
Views
308
  • Programming and Computer Science
Replies
2
Views
2K
  • Special and General Relativity
Replies
6
Views
1K
Back
Top