Apify and Crawlee Official Forum

Updated 3 months ago

Typescript export/import causing build errors

I built my first actor today using the Typescript/Crawlee/Cheerio template. I’m a front end developer that uses Typescript every day, so this felt comfortable at first. I quickly ran into build problems though. I split my code into multiple files that exported functions and some types, however the build failed as it did not like my imports into main.ts. No matter how I tried to import my helper functions I would get linting and build errors. I ended up copy pasting my code into main.ts, which did work, but this seems unnecessary. What is the correct approach to splitting my code so that I can import into main.ts?
S
O
2 comments
Hey , our team will reply to you soon.
Can you please provide some reproduction?
Code on the Apify platform would be the best.

Also, try to use ready templates:
https://docs.apify.com/platform/actors/development/quick-start/locally#2-create-your-actor

It has some basic structure with ready modules and there shouldn't be any issues with creating new modules / separate files.
Add a reply
Sign up and join the conversation on Discord