Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
['hashchange', 'load'].forEach(ev => console.log(ev)); does not work with Parcel?

I am following a tutorial in which the following line works:

['hashchange', 'load'].forEach(ev => console.log(ev));

I write it and I get:

Uncaught TypeError: Cannot read properties of undefined (reading 'forEach')
    at Object.eval (eval at hmrApply (runtime-378176c723eb17dd.js:297), <anonymous>:143:12)
    at newRequire (index.05cf099e.js:71)
    at hmrAcceptRun (runtime-378176c723eb17dd.js:370)
    at WebSocket.ws.onmessage (runtime-378176c723eb17dd.js:127)

The project is using Parcel: parcel index.html.
It also imports core-js/stable and regenerator-runtime/runtime.

If I create a variable holding the array and then call forEach() on that array it works:

const arr = ['hashchange', 'load'];
arr.forEach(ev => console.log(ev));

at Object.eval (eval at hmrApply (runtime-378176c723eb17dd.js:297), :143:12):

function hmrApply(bundle
/*: ParcelRequire */
, asset
/*:  HMRAsset */
) {
  var modules = bundle.modules;

  if (!modules) {
    return;
  }

  if (asset.type === 'css') {
    reloadCSS();
  } else if (asset.type === 'js') {
    var deps = asset.depsByBundle[bundle.HMR_BUNDLE_ID];

    if (deps) {
   var fn = new Function('require', 'module', 'exports', asset.output); // line 297
      modules[asset.id] = [fn, deps];
    } else if (bundle.parent) {
      hmrApply(bundle.parent, asset);
    }
  }
}

at newRequire (index.05cf099e.js:71):

  function newRequire(name, jumped) {

// a big function

      var module = (cache[name] = new newRequire.Module(name));

   modules[name][0].call( // line 71
        module.exports,
        localRequire,
        module,
        module.exports,
        this
      );
    }

at hmrAcceptRun (runtime-378176c723eb17dd.js:370):

function hmrAcceptRun(bundle
/*: ParcelRequire */
, id
/*: string */
) {
// a big function
  bundle(id); // line 370
  cached = bundle.cache[id];

at WebSocket.ws.onmessage (runtime-378176c723eb17dd.js:127)

  ws.onmessage = function (event
  /*: {data: string, ...} */
  ) {
// a big function
          if (!acceptedAssets[id]) {
            hmrAcceptRun(assetsToAccept[i][0], id); // line 127
          }
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!