Casper
Casper3y 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_k3y 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 Krivka3y ago
You must have changed something from the template
Casper
CasperOP3y ago
Gist
apify docker file
apify docker file. GitHub Gist: instantly share code, notes, and snippets.
Casper
CasperOP3y ago
Hmm I will try to delve into what might be changed
Casper
CasperOP3y ago
Gist
apify tsconfig.json - modified
apify tsconfig.json - modified. GitHub Gist: instantly share code, notes, and snippets.
Casper
CasperOP3y 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
adverse-sapphire
adverse-sapphire15mo ago
did you ever fix this? I'm running into same issue
Oleg V.
Oleg V.15mo 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?