Miguelii
Miguelii

Reputation: 67

SyntaxError: Unexpected token 'export' when using CrafterCMS with typescript

I'm trying to create a crafterCMS project with typescript. I install the latest packages:

"@craftercms/content": "^2.0.7",
"@craftercms/experience-builder": "^1.0.0-rc.3",
"@craftercms/ice": "^2.0.7",

But when i run the project i get this error: enter image description here

By checking the logs its coming from a file belonging to @craftercms/experience-builder in node_modules:

enter image description here

If i don't use typescript i dont get any errors so my guess its because of these typescript files in node_modules:

enter image description here

Any solution?

Upvotes: 0

Views: 86

Answers (1)

Miguelii
Miguelii

Reputation: 67

I manage to solve the problem using next transpile modules. I added

const withTM = require('next-transpile-modules')(['@craftercms/experience-builder','@craftercms/studio-ui']);

to next.config.js and then export using that

module.exports = withTM({...});

Upvotes: 0

Related Questions