title: Typescript: Cannot find module XWZ or its corresponding type declarations in Docker Container
body: <p>Environment: Docker container running nodejs image.</p>
  <p>The api works fine. The ts-node-dev is running perfectly, no issue with express or other packages.
  the db is also working, I've tested it through workbench.</p>
  <p>The error stated when I tryied to use an ORM to connect to the database. I tried two of them: TypeORM and Sequelize. Both fired the same type of error:</p>
  <p><code>error TS2307: Cannot find module 'sequelize' or its corresponding type declarations.</code></p>
  <p>I don't know if it's something with the Typescript compiler or the docker environment. Because this only happens when I run the app inside the container through <code>docker-compose up</code>.</p>
  <p>Something that I noticed is that both of these libs use inside-of-lib type declarations, I mean, there are no @types/sequelize</p>
  <p>This is the repository to reproduce the error:
  <a href="https://bitbucket.org/carloseustaquio/test-cicd-docker/src/master/" rel="nofollow noreferrer">https://bitbucket.org/carloseustaquio/test-cicd-docker/src/master/</a></p>
  <p>Dockerfile</p>
  <pre><code>FROM node:12
  
  RUN mkdir -p /home/node/api/node_modules &amp;&amp; chown -R node:node /home
  
  WORKDIR /home/node/api
  
  COPY package.json yarn.* ./
  
  USER node
  
  RUN yarn
  
  COPY --chown=node:node . .
  
  EXPOSE 8080
  
  ENTRYPOINT [ &quot;./init.sh&quot; ]
  </code></pre>
  <p>docker-compose.yaml</p>
  <pre><code>version: '3'
  
  services:
    nodejs-app:
      container_name: nodejs-app
      build: '.'
      volumes:
        - .:/home/node/api
        - /home/node/api/node_modules
      networks:
        - app-connect
      ports:
        - '8080:8080'
      depends_on: 
        - database
      environment: 
        - DB_URI=mysql://root:password@database/db?charset=UTF8
  
    database:
      image: mysql:5.7
      environment: 
        - MYSQL_ROOT_PASSWORD=password
        - MYSQL_DATABASE=db
      ports: 
        - 0.0.0.0:7200:3306
  
  networks:
    app-connect:
        driver: bridge
  </code></pre>
  <p>package.json</p>
  <pre><code>{
    &quot;name&quot;: &quot;test-docker&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;testing docker envairoment&quot;,
    &quot;main&quot;: &quot;index.js&quot;,
    &quot;scripts&quot;: {
      &quot;dev&quot;: &quot;ts-node-dev --respawn --ignore-watch node_modules --no-notify index.ts&quot;,
      &quot;build&quot;: &quot;tsc&quot;,
      &quot;start&quot;: &quot;node dist/index.js&quot;,
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
    },
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;dependencies&quot;: {
      &quot;dotenv&quot;: &quot;^8.2.0&quot;,
      &quot;express&quot;: &quot;^4.17.1&quot;,
      &quot;mysql2&quot;: &quot;^2.1.0&quot;,
      &quot;sequelize&quot;: &quot;^6.3.5&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@types/express&quot;: &quot;^4.17.8&quot;,
      &quot;@types/node&quot;: &quot;12&quot;,
      &quot;@types/validator&quot;: &quot;^13.1.0&quot;,
      &quot;ts-node-dev&quot;: &quot;^1.0.0-pre.61&quot;,
      &quot;typescript&quot;: &quot;^4.0.2&quot;
    }
  }
  
  </code></pre>
  <p>tsconfig.json</p>
  <pre><code>{
    &quot;compilerOptions&quot;: {
      &quot;target&quot;: &quot;es2017&quot;,
      &quot;module&quot;: &quot;commonjs&quot;,
      &quot;moduleResolution&quot;: &quot;node&quot;,
      &quot;lib&quot;: [
        &quot;es6&quot;
      ],
      &quot;typeRoots&quot;: [
        &quot;./node_modules/@types&quot;,
        &quot;./src/@types&quot;,
      ],
      &quot;allowJs&quot;: true,
      &quot;outDir&quot;: &quot;./dist&quot;,
      &quot;rootDir&quot;: &quot;.&quot;,
      &quot;strict&quot;: true,
      &quot;esModuleInterop&quot;: true,
      &quot;noImplicitAny&quot;: false,
      &quot;skipLibCheck&quot;: true,
      &quot;forceConsistentCasingInFileNames&quot;: true,
      &quot;resolveJsonModule&quot;: true,
      &quot;experimentalDecorators&quot;: true,
      &quot;emitDecoratorMetadata&quot;: true,
    }
  }
  </code></pre>