

- CANNOT USE IMPORT STATEMENT OUTSIDE A MODULE HOW TO
- CANNOT USE IMPORT STATEMENT OUTSIDE A MODULE CODE
Using the sample ES5 code from this page of the guide works. I discovered this was occurring because I was using the supplied ESNext JavaScript code from the guide.Īlthough it is never once mentioned in the "Store Post Meta with a Block" guide, this page in a later section confirms the ESNext code must be "compiled" before it can be used. Data is saved to post meta via the hook
CANNOT USE IMPORT STATEMENT OUTSIDE A MODULE HOW TO
Anyone have any suggestions on how to resolve this I have also tried creating a brand new vue. Register_post_meta( 'post', 'myguten_meta_block_field', array(Īdd_action( 'init', 'myguten_register_post_meta' ) Īrray( 'wp-blocks', 'wp-element', 'wp-components', 'wp-data', 'wp-core-data', 'wp-block-editor' )Īdd_action( 'enqueue_block_editor_assets', 'myguten_enqueue' ) Synta圎rror: Cannot use import statement outside a module. Make sure that you are importing from dist. The Uncaught syntaxerror: cannot use import statement outside a module occurs if you have. Solution 3 Use import and require to load the modules. Solution 2 Add typemodule attribute to the script tag. Myguten-meta-block.php: // register custom meta tag field JS Error - cannot use import statement outside a module Make sure that you have the typemodule attribute set. How to fix cannot use import statement outside a module error Solution 1 Add type: module to package.json. How can I resolve this? Is the WordPress Block Editor Handbook code incorrect?

However, the block does not load and a Uncaught Synta圎rror: Cannot use import statement outside a module error is displayed from the myguten.js file in the console when loading the block editor page. Users/./node_modules/sucrase/dist/index.I am following the " Store Post Meta with a Block" guide from the official Block Editor Handbook to add a custom post meta block using the supplied sample code (below). You'll find more details and examples of these config options in the docs:įor information about custom transformations, see: TypeError: MiniCssExtractPlugin is not a constructor Solving the Uncaught Synta圎rror: Cannot use import statement outside a module Remove element from. binary assets) you can stub them out with the "moduleNameMapper" config option.
