Sublime3 importing node modules from a docker container

  docker, sublimetext, sublimetext3, typescript

I am building a small API with express and I have dockerized the express application in an alpine docker container. As the node_modules can get a bit too much (also I have read a lot of blog posts on how they could also be insecure) I decided to have them only in the docker container.

Everything is working great, except my Sublime3 text editor, as it cannot find the node_modules and underlines the imports with the error message:

Cannot find module "express" or its corresponding type declaration.

I am not using require to import the module, as I am using typescript (decided I might as well learn it on the way), so I am importing express like this:

import * as express from "express";

I assume Sublime3 is not finding the module, as it is available in the Docker container (in a volume) and not locally, however, I may also be importing express wrongly, as I am fairly new to typescript. Would very much appreciate it if someone could share how they have setup their sublime3 text editor for typescript, when using docker!

Source: Docker Questions

LEAVE A COMMENT