Truffle Uncaught ReferenceError: global is not defined after using migrate

Viewed 1779

I'm following this tutorial. After using the command truffle migrate --reset the blocks appear on Ganache GUI. However, I'm not able to interact with the contract using the console. If I type token = await MemoryToken.deployed(), I receive the following error:

truffle(development)> let token = await MemoryToken.deployed()
Uncaught ReferenceError: global is not defined at evalmachine.<anonymous>:2:19

I have no idea why. I tried this several time with the same result. What am I missing ?

The same happens with the tutorial from the truffle website.

4 Answers

A temporary workaround is to explicitly define global in the REPL:

global = this

Try

truffle(development)> let token = MemoryToken.deployed()

It worked for me. I don't know much more about the error

I had same issue. Changed node version from v12.22.4 to v10.16.0.

I had the same problem in the MetaCoin example with Truffle v5.4.5 (core: 5.4.5), Solidity v0.5.16 (solc-js), Node v14.14.0, Web3.js v1.5.1. It works after downgrading Truffle to version v5.4.3 as suggested by @ovo.

Related