national-gold
national-gold2y ago

Error: Error: Cannot find module '/home/myuser/dist/main.js'

I am getting the error: Error:
Cannot find module '/home/myuser/dist/main.js'
Cannot find module '/home/myuser/dist/main.js'
when trying to run a successfull build for my actor on Apify, but locally it works without errors. I have disabled a lot of linting and warnings as they serve me no real purpose other than stop my typescript compliation from succeeding. It is a Typescript Crawlee project. Do you have any idea of what might be the cause?
8 Replies
ondro_k
ondro_k2y ago
Hi, it looks like docker build doesn't put built js files to the right place. Could you share the content of your Dockerfile?
Lukas Krivka
Lukas Krivka2y ago
You must have changed something from the template
national-gold
national-goldOP2y ago
Gist
apify docker file
apify docker file. GitHub Gist: instantly share code, notes, and snippets.
national-gold
national-goldOP2y ago
Hmm I will try to delve into what might be changed
national-gold
national-goldOP2y ago
Gist
apify tsconfig.json - modified
apify tsconfig.json - modified. GitHub Gist: instantly share code, notes, and snippets.
national-gold
national-goldOP2y ago
I have done the cahnges in tsconfig to try to disable warnings for unused variables as this should not make compilation fail as it is just a warning not a critical error
stormy-gold
stormy-gold13mo ago
did you ever fix this? I'm running into same issue
Oleg V.
Oleg V.12mo ago
I gues for module options You should use "NodeNext":
{
"extends": "@apify/tsconfig",
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2022",
"outDir": "dist",
"noUnusedLocals": false,
"skipLibCheck": true,
"lib": ["DOM"]
},
"include": [
"./src/**/*"
]
}
{
"extends": "@apify/tsconfig",
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2022",
"outDir": "dist",
"noUnusedLocals": false,
"skipLibCheck": true,
"lib": ["DOM"]
},
"include": [
"./src/**/*"
]
}
Otherwise, just update apify-cli to the latest version and regenerate it from the template.

Did you find this page helpful?