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.

Checkout page Evaluation failed: TypeError: Cannot read property 'getAttribute' of null

See original GitHub issue

Followed setup instructions from https://github.com/magesuite/magepack and https://github.com/magesuite/magepack-magento 2.3.4

Platform OS: OSX PHP: PHP 7.3 MAGENTO: 2.3.4

STEPS I TOOK:

  • npm install -g magepack
  • composer require creativestyle/magesuite-magepack
  • composer require cweagans/composer-patches
  • ADDED COMPOSER UPDATES AND ADDED M2.3.4 PATCH FROM
"extra": {
        "magento-force": "override",
        "composer-exit-on-patch-failure": true,
        "patches": {
            "magento/magento2-base": {
                "Refactor JavaScript mixins module https://github.com/magento/magento2/pull/25587": "patches/composer/M234/github-pr-25587-base.diff"
            }
        }
    },
  • magepack generate --cms-url=“{{DOMAIN}}” --category-url=“{{DOMAIN}}en/buy-x-get-y.html” --product-url=“{{DOMAIN}}en/affirm-water-bottle.html” [WITH actual domain names of my env]

And am seeing this below messages with error Evaluation failed: TypeError: Cannot read property 'getAttribute' of null

ℹ Collecting bundle modules in the browser.                                                                                                                                                                                                                                                                                                                                                                                                                                       23:42:25
ℹ Collecting modules for bundle "category".                                                                                                                                                                                                                                                                                                                                                                                                                                       23:42:25
✔ Finished collecting modules for bundle "category".                                                                                                                                                                                                                                                                                                                                                                                                                              23:42:36
ℹ Collecting modules for bundle "cms".                                                                                                                                                                                                                                                                                                                                                                                                                                            23:42:36
✔ Finished collecting modules for bundle "cms".                                                                                                                                                                                                                                                                                                                                                                                                                                   23:42:45
ℹ Collecting modules for bundle "product".                                                                                                                                                                                                                                                                                                                                                                                                                                        23:42:45
✔ Finished collecting modules for bundle "product".                                                                                                                                                                                                                                                                                                                                                                                                                               23:42:54
ℹ Collecting modules for bundle "checkout".                                                                                                                                                                                                                                                                                                                                                                                                                                       23:42:54

 ERROR  Evaluation failed: TypeError: Cannot read property 'getAttribute' of null                                                                                                                                                                                                                                                                                                                                                                                                 23:42:58
    at __puppeteer_evaluation_script__:11:30
    at Array.forEach (<anonymous>)
    at __puppeteer_evaluation_script__:6:11

  at __puppeteer_evaluation_script__:11:30
  at Array.forEach (<anonymous>)
  at __puppeteer_evaluation_script__:6:11
  at ExecutionContext._evaluateInternal (/Users/ela/.nvm/versions/node/v12.7.0/lib/node_modules/magepack/node_modules/puppeteer/lib/ExecutionContext.js:122:13)
  at processTicksAndRejections (internal/process/task_queues.js:85:5)
  at async ExecutionContext.evaluate (/Users/ela/.nvm/versions/node/v12.7.0/lib/node_modules/magepack/node_modules/puppeteer/lib/ExecutionContext.js:48:12)
  at async Object.checkout (/Users/ela/.nvm/versions/node/v12.7.0/lib/node_modules/magepack/lib/generate/collector/checkout.js:41:5)
  at async module.exports (/Users/ela/.nvm/versions/node/v12.7.0/lib/node_modules/magepack/lib/generate.js:24:13)
  -- ASYNC --
  at ExecutionContext.<anonymous> (/Users/ela/.nvm/versions/node/v12.7.0/lib/node_modules/magepack/node_modules/puppeteer/lib/helper.js:111:15)
  at DOMWorld.evaluate (/Users/ela/.nvm/versions/node/v12.7.0/lib/node_modules/magepack/node_modules/puppeteer/lib/DOMWorld.js:112:20)
  at processTicksAndRejections (internal/process/task_queues.js:85:5)
  -- ASYNC --
  at Frame.<anonymous> (/Users/ela/.nvm/versions/node/v12.7.0/lib/node_modules/magepack/node_modules/puppeteer/lib/helper.js:111:15)
  at Page.evaluate (/Users/ela/.nvm/versions/node/v12.7.0/lib/node_modules/magepack/node_modules/puppeteer/lib/Page.js:860:43)
  at Page.<anonymous> (/Users/ela/.nvm/versions/node/v12.7.0/lib/node_modules/magepack/node_modules/puppeteer/lib/helper.js:112:23)
  at Object.checkout (/Users/ela/.nvm/versions/node/v12.7.0/lib/node_modules/magepack/lib/generate/collector/checkout.js:41:16)
  at processTicksAndRejections (internal/process/task_queues.js:85:5)
  at async module.exports (/Users/ela/.nvm/versions/node/v12.7.0/lib/node_modules/magepack/lib/generate.js:24:13)

Some help on whats this error is about and how to debug this to resolve will be really helpful and much appreciated.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
twwheelercommented, Oct 27, 2020

Don’t know if it’s helpful, but having just had a similar issue: make sure that the page you’re using for --product-url has a purchasable product. If it’s out of stock and can’t be added to cart, bad things happen.

1reaction
twwheelercommented, Oct 28, 2020

@Elamurugan-Nallathambi : our site had similar requirements; most of the products are behind a ZIP code/age validation. What I did was point the product-url to a page that had a simple purchase product. The bundler was able to find our scripts as they were coded into a common script destination that is shared with other functions, but maybe yours is different.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Cannot read property 'getAttribute' of ...
The problem is because document.getElementById("image") in your script is called even before the targetted element is loaded which returns ...
Read more >
Uncaught TypeError: Cannot read property of null - iDiallo
In some cases, this error is a symptom of another issue. Why would getElementById return null if the element actually exists on the...
Read more >
Cannot read properties of null (reading 'getAttribute')
To solve the "TypeError: Cannot read properties of null (reading 'getAttribute')" error, make sure the id you're using to get the element exists...
Read more >
Learning JavaScript by Example - Mitch Fincher's Home Page
For example, to add the "last updated line" to your pages, ... Exception: TypeError: Cannot read properties of null (reading 'to_s')
Read more >
React TypeError: Cannot read property function of undefined
SET YOUR LIKE THERE ... Your browser can't play this video. ... Solved: React TypeError : Cannot read property function of undefined.
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