ReferenceError: TextDecoder is not defined

Hi all

Operating system: Linux
Truffle version: Version: 0.8.7+commit.e28d00a7.Linux.g++
Truffle-upgrades version: v1.9.0
truffle/hdwallet-provider version: 1.5.0
Truffle v5.4.3 (core: 5.4.3)
Solidity - 0.8.7 (solc-js)
Node v10.19.0
Web3.js v1.5.0
Network: mainnet

This error occurs in this file during migration:

// migrations/2_deploy_upgradeable.js
const { deployProxy } = require('@openzeppelin/truffle-upgrades');

const myTokenU = artifacts.require('MyToken');

module.exports = async function (deployer) {
  const instance = await deployProxy(myTokenU, ["MyToken", "MET", 100000000], { deployer, initializer: 'initialize' });
  console.log('Deployed', instance.address);

The error:


const td = new TextDecoder('utf8', {fatal: true, ignoreBOM: true})

ReferenceError: TextDecoder is not defined

How to fix this? Thank you very much.

Best regards,

Please try removing node_modules and reinstalling dependencies. This looks like an error in your setup.

I am having the same issue..
It was running yesterday. I restarted the PC, delete node_modules and still have the same error. I am running the example of upgradable Box. I am still havin the error:
/@openzeppelin/upgrades-core/node_modules/nofilter/lib/index.js:5 ReferenceError: TextDecoder is not defined

I am also facing the same issue. Please let me know If It is resolved? Thanks

If someone can provide a repository where we can reproduce the issue we will be able to look into it.

node10 seems to be the problem, since native support for TextDecoder is only available with node11 or newer. It seems to be that node10 is no longer supported by some of the dependencies (like nofilter, but also others). Upgrading to node16 solved the issue for me.

Node 10 is no longer maintained. You should use Node 12 or higher.