2

This error suddenly appears out of nowhere. i tried reinstalling the npm packages but it doesn't work. but when it works when i create a fresh project of jetstream-inertia with the same npm packages. Any Help? Tested on Chrome:

app.js:10 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'dataset')
    at exports.createInertiaApp (app.js:10)
    at Module../resources/js/app.js (app.js:27154)
    at __webpack_require__ (app.js:53738)
    at app.js:53903
    at Function.__webpack_require__.O (app.js:53775)
    at app.js:53905
Md Arif Islam
  • 57
  • 2
  • 6

2 Answers2

3

You need to add the defer attribute to your script tag within the head tag like so :

<head>
  ........
 
  <script src="{{ mix('/js/app.js') }}" defer></script>
</head>

Alternatively, you could add the script just below the @inertia tag in the scripts section excluding the defer attribute like so:

@inertia
<script src="{{ mix('/js/app.js') }}"></script> 
.......
</body>
Macdonald
  • 880
  • 7
  • 21
2

just put the script tag after @inertia tag in HTML. this error occurred because the script tag was in the head tag and vue couldn't find the #app element. i believe you removed the "defer" attribute from the script tag. either add the defer attribute or load the app.js at the end.

Ariful
  • 29
  • 1
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Gary Houbre Nov 19 '21 at 08:22
  • Yeah could you elaborate on the answer – ii iml0sto1 Jan 06 '22 at 18:02