S
S
slip312018-12-30 21:37:14
JavaScript
slip31, 2018-12-30 21:37:14

Why does not see the module?

Good afternoon. Something stupid. There is a controller

import { Request, Response } from "express";

export let index = (req: Request, res: Response) => {
  console.log("home");
};

As a separate module I do not export, just index.
in app.ts
import * as homeController from "../src/modules/home/controllers/home.controller";
const app = express();
...
app.get("/", homeController.index);

tslint passes, but at startup
internal/modules/cjs/loader.js:589
    throw err;
    ^
Error: Cannot find module '../src/modules/home/controllers/home.controller'

The path is correct. And Vscode doesn't swear
Where did I go wrong?
And Happy New Year

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Andreev, 2019-12-31
@Pibodi

When you import write the extension at the end.

import * as homeController from "../src/modules/home/controllers/home.controller.js";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question