I have a problem with deploying my project onto server, on my pc everything works fine and there is no imports problems. Thank you for ur help!
Error Message:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/igor/backend/alina_edu/router/articleRoutes.js' imported from /home/igor/backend/alina_edu/index.js
at new NodeError (internal/errors.js:322:7)
at finalizeResolution (internal/modules/esm/resolve.js:318:11)
at moduleResolve (internal/modules/esm/resolve.js:776:10)
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:887:11)
at Loader.resolve (internal/modules/esm/loader.js:89:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:76:40)
at link (internal/modules/esm/module_job.js:75:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Imports from index.js:
import courseRoutes from "./router/CourseRoutes.js";
import authRoutes from './router/authRoutes.js';
import articleRoutes from './router/articleRoutes.js';
import tagsRouter from "./router/TagsRouter.js";
import testsRoutes from "./router/TestsRoutes.js";
Package.json module annotation
"main": "index.js",
"type": "module",
ArticleRoutes.js itself
import {Router} from "express";
import ArticleController from "../controllers/ArticleController.js";
const articleRoutes = new Router();
// ...blah-blah-blah...
export default articleRoutes;
Server settings:
Are you developing on a Windows machine and deploying to an Ubuntu machine?
Your files have capital letters in them (e.g. CourseRoutes.js), which Windows ignores. Filenames in Windows are case-insensitive, but case-sensitive in Ubuntu, so if the upper/lowercase, it will work on Windows but fail in Ubuntu.
If you're using source control, check the case of the filenames in the web interface (e.g. GitHub) or by cloning a new repo. If you aren't using source control, use source control.