SyntaxError: Cannot use import statement outside a module

When I use GLTF Export script
Syntax Error: Cannot use import statement outside a module

this error come any one help me ?

ES modules are not supported in Code Editor yet. You would need to use some bundler to transpile it to commonjs.

can you help me how ?

This is not really a PlayCanvas issue, but a generic Javascript problem. It depends on what tools you use. You should google how to transpile JS files. There are plenty of tutorials and guides available. Pick the one that matches your toolchain.

I am using Playcanvas GTLF Exporter script

This script I am using

I am using Playcanvas and using GLTF Scripts which you guys provide me.

As I mentioned, you should use some bundler, like webpack or rollup to transpile it from ES module to commonjs. This is out of scope issue and you can google how to transpile Javascript using a bundler.

Using the script directly as-is in Code Editor is not supported.

As LeXXik mentioned you can’t normally use that in an editor based project. There is an alternative if you’d like to give it a try (answered with that in your other post too):

1 Like

Hi Brother i solve my problem
i just i want to share how i solve in core-exporter and glb exporter you dnt need to do anything just go on script and turn of preloader thats its. it work
thank you guys for helping

1 Like