bombillazo10mo ago

Syntax Error: Unexpected token 'export'

Hello, We are using Supabase Deno Edge Functions and are getting this error while trying to import a file into an edge function code: Uncaught SyntaxError: Unexpected token 'export' at file:///home/deno/modules/c675a10248170410cad4e4a996152aad5ad7f2a817728186567122b6394d9419:185:1 InvalidWorkerCreation: worker boot error I checked the edge runtime file and the file code is as my source code, yet the edge function fails to run throwing this error. I'm not sure why this is happening though.
3 Replies
Deno AI Helper
Deno AI Helper10mo ago
Based on the documentation, Deno supports ECMAScript modules exclusively. If you're seeing an Unexpected token 'export' error, it's likely that the module you're trying to import is not being recognized as an ECMAScript module. Here are a few things you could check: 1. File extension: Deno determines the type of a local module based on its extension. Make sure the file you're trying to import has a .ts or .js extension. 2. Import statement: In Deno, you should use the import keyword to import modules. Make sure you're not using require, which is used in Node.js but not supported in Deno. 3. Export statement: Check the file you're importing from. If it's using module.exports to export values, you'll need to change it to use the export keyword instead. 4. Absolute URLs: Deno allows importing from absolute file or HTTPS URLs. If you're importing from an absolute URL, make sure the URL is correct. If you've checked all of these and you're still seeing the error, it might be helpful to share the code that's causing the issue so we can provide more specific advice. 🦕
bombillazo10mo ago
thanks, but I've already checked those
ioB10mo ago
Is this open-source? Could you send the code? Sometimes a token error will happen in a completely unrelated place and it's a syntax issue elsewhere.