[wp-trac] [WordPress Trac] #62324: uncaught syntaxerror

WordPress Trac noreply at wordpress.org
Tue Dec 10 08:25:13 UTC 2024


#62324: uncaught syntaxerror
--------------------------+------------------------------
 Reporter:  ramonapoly    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by salmankhan0909):

 This error, "Uncaught SyntaxError: Cannot use import statement outside a
 module", typically occurs because the JavaScript file is being treated as
 a regular script rather than a module.

 Method 1. Add type="module" in the script tag

 {{{#!php
 <?php
 <script type="module" src="https://urbanblogsphere.my.id/wp-
 includes/blocks/navigation/view.min.js?ver=6.6.1"></script>

 }}}

 **Reason:** The import statement can only be used within JavaScript
 modules. Adding type="module" ensures the browser treats it as such.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62324#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list