Skip to main content
  • Guides & Documentation

Knowledgebase

Featured articles, how-to guides and quick tips.

Drupal 8 JS Errors: Cannot read property 'currentPath' of undefined

Your Drupal front-end might be throwing Uncaught TypeErrors in the JavaScript console, such as:

Uncaught TypeError: Cannot read property 'permissionsHash' of undefined
Uncaught TypeError: Cannot set property 'StateModel' of undefined
Uncaught TypeError: Cannot set property 'AuralView' of undefined
Uncaught TypeError: Cannot set property 'KeyboardView' of undefined
Uncaught TypeError: Cannot set property 'RegionView' of undefined
Uncaught TypeError: Cannot set property 'VisualView' of undefined
Uncaught TypeError: Cannot read property 'uid' of undefined
Uncaught TypeError: Cannot read property 'currentPath' of undefined
Uncaught TypeError: Cannot read property 'currentPathIsAdmin' of undefined
Uncaught TypeError: Cannot read property 'url' of undefined
Uncaught TypeError: Cannot read property 'currentQuery' of undefined

... the list goes on.

A common cause of these errors is that the following line in your html.html.twig file is wrapped or enclosed in a <div> tag, or some other type of container element:

<js-bottom-placeholder token="{{ placeholder_token|raw }}">

The trick is, that you may not see a wrapping element within the html.html.twig file.

Commonly, this issue is caused by another unclosed tag somewhere else in the DOM of your Drupal frontend.

In this case, it's usually the active theme that's at fault. There is likely some tag somewhere in your DOM that remains unclosed, and therefore the browser is rendering the page with the above syntax from html.html.twig enclosed/wrapped in a tag that it shouldn't be.

You're not likely to see this directly in your html.html.twig file, or in the page source, so in order to track down the unclosed tag efficiently, you'll have to run the page through a tool such as the W3C validator.

It's surprising the havoc unclosed tags can cause.

Happy theming!