Cannot find module after build with typescript

This is my typescript config
{
"extends": "@apify/tsconfig",
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "node",
"outDir": "./dist",
"strict": true,
"noImplicitAny": false,
"strictNullChecks": false,
"esModuleInterop": true,
"declaration": true,
"lib": ["DOM", "DOM.Iterable", "ES2022"]
},
"include": ["./src/**/*"]
}
{
"extends": "@apify/tsconfig",
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "node",
"outDir": "./dist",
"strict": true,
"noImplicitAny": false,
"strictNullChecks": false,
"esModuleInterop": true,
"declaration": true,
"lib": ["DOM", "DOM.Iterable", "ES2022"]
},
"include": ["./src/**/*"]
}
This is my package json
"main": "dist/main.js",
"engines": {
"node": ">=16.0.0"
},
"scripts": {
"start": "npm run start:dev",
"start:prod": "node dist/main.js",
"start:dev": "./dev.sh && ts-node-esm -T src/main.ts ",
"build": "tsc",
"lint": "eslint ./src --ext .ts",
"lint:fix": "eslint ./src --ext .ts --fix",
"test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1"
},
"main": "dist/main.js",
"engines": {
"node": ">=16.0.0"
},
"scripts": {
"start": "npm run start:dev",
"start:prod": "node dist/main.js",
"start:dev": "./dev.sh && ts-node-esm -T src/main.ts ",
"build": "tsc",
"lint": "eslint ./src --ext .ts",
"lint:fix": "eslint ./src --ext .ts --fix",
"test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1"
},
build happening and i see that dist folder created everything fine, but when im trying to run it locally with yarn start:prod i see error (screenshot attachment) looks like it's trying to reach d.ts file instead of correct routes file not sure how to fix it, i just followed official guide from crawlee dock.
No description
16 Replies
correct-apricot
correct-apricotOP3y ago
It looks like issue happening on configuration level, does author of documentation https://crawlee.dev/docs/guides/typescript-project
TypeScript Projects | Crawlee
Stricter, safer, and better development experience
correct-apricot
correct-apricotOP3y ago
tried to use it?
Pepa J
Pepa J3y ago
Hello @Ararat Martirossyan Try to put *.js on the end of the import path. so it would be something like:
import { router } from './routes.js';
import { router } from './routes.js';
Also I highly suggest you to create a new project with Crawlee CLI
npx crawlee create my-crawler
npx crawlee create my-crawler
Which should solve these initial things for you.
correct-apricot
correct-apricotOP3y ago
Let me try .js is fixing issue, but i need to do it manually? Because i cannot find the way to add .js during bundle
dependent-tan
dependent-tan3y ago
It's a typescript thing, and probably there's a way to add it automatically (some IDE settings), but I just do it manually, yes
correct-apricot
correct-apricotOP3y ago
Yes i have too many imports to add it manually, it can be a problematic for me to do it manually
dependent-tan
dependent-tan3y ago
As mentioned - I don't have a working solution to do it automatically, so maybe someone else could comment...
correct-apricot
correct-apricotOP3y ago
It's alright, it started to work but Input cannot be used anymore by some reasons
No description
dependent-tan
dependent-tan3y ago
how to you get the input though? I mean - how to you parse it? Any chance you removed INPUT.json by occasion, or something like that?
correct-apricot
correct-apricotOP3y ago
Im creating input in APIFY panel, and trying to get it from code.
No description
No description
correct-apricot
correct-apricotOP3y ago
I used with Apify and it worked this way, now it returns null, should i commit INPUT.json within my code? If yes then how i can change it dynamically?
Pepa J
Pepa J3y ago
@Ararat Martirossyan You need to call await Actor.getInput() after the await Actor.init()
correct-apricot
correct-apricotOP3y ago
i thought it was for v2
dependent-tan
dependent-tan3y ago
You should still be able to use it the same way as you have it now, but it has to be after Actor.init() call Actor.init() (besides some other things generally) sets storage client to Apify client in this case. So when you call it before (as you have now) - it tried to fetch input via memory-storage (crawlee default), and Input.json does not exist there, so you get null
correct-apricot
correct-apricotOP3y ago
got it Thank you to everyone! I wanted to take a moment to express my gratitude for Apify Crawlee - it's been an incredibly useful tool for our company's scraping needs. We've developed 100 scrapers using Crawlee and Apify, and we're currently in the process of migrating to v3. However, we've encountered some issues along the way that we're working to resolve. By the way, I had a quick question - is there a limit on the number of actors that can be created with Apify Crawlee? I'd appreciate any insight you can provide. Thank you!
Pepa J
Pepa J3y ago
@Ararat Martirossyan Yes there is a limitation, check https://docs.apify.com/platform/limits
Limits | Apify Documentation
Learn the Apify platform's resource capability and limitations such as max memory, disk size and number of actors and tasks per user.

Did you find this page helpful?