title: error TS1259: Module '"./node_modules/@types/express/index"' can only be default-imported using the 'esModuleInterop' flag
body: <p>I'm trying to import express into the project and in the middle of the development, it just stopped working, i've reseted configurations, etc. Can't make it work, can't import any modules.</p>
  <pre><code>npx tsc src/server.ts 
  src/server.ts:1:8 - error TS1259: Module '&quot;/home/fpc-ubut/Git/nlw2/server/node_modules/@types/express/index&quot;' can only be default-imported using the 'esModuleInterop' flag
  
  1 import express from 'express';
  </code></pre>
  <pre><code>src/database/migrations/00_create_users.ts:1:8 - error TS1259: Module '&quot;/home/fpc-ubut/Git/nlw2/server/node_modules/knex/types/index&quot;' can only be default-imported using the 'esModuleInterop' flag
  
  1 import Knex from 'knex'
  </code></pre>
  <pre><code>src/server.ts:1:8 - error TS1259: Module '&quot;path&quot;' can only be default-imported using the 'esModuleInterop' flag
  
  1 import path from 'path'
  </code></pre>
  <p>Enviroment
  OS: Ubuntu 20.04.1 LTS<br />
  node: v12.18.1<br />
  packages:</p>
  <pre><code>    &quot;@types/express&quot;: &quot;^4.17.6&quot;,
      &quot;@types/node&quot;: &quot;^14.0.27&quot;,
      &quot;ts-node&quot;: &quot;^8.10.2&quot;,
      &quot;ts-node-dev&quot;: &quot;^1.0.0-pre.44&quot;,
      &quot;typescript&quot;: &quot;^3.9.3&quot;
  
      &quot;express&quot;: &quot;^4.17.1&quot;,
      &quot;knex&quot;: &quot;^0.21.1&quot;,
      &quot;pg&quot;: &quot;^8.2.1&quot;
  </code></pre>
  <p>EDIT1:
  as asked, here is my tsconfig.json. But the configuration (&quot;esModuleInterop&quot;: true), is already as aspected</p>
  <p>&lt;tsconfig.json&gt;</p>
  <pre><code>
      {
        &quot;compilerOptions&quot;: {
          /* Visit https://aka.ms/tsconfig.json to read more about this file */
      
          /* Basic Options */
          // &quot;incremental&quot;: true,                   /* Enable incremental compilation */
          &quot;target&quot;: &quot;es5&quot;,                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
          &quot;module&quot;: &quot;commonjs&quot;,                     /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
          // &quot;lib&quot;: [],                             /* Specify library files to be included in the compilation. */
          // &quot;allowJs&quot;: true,                       /* Allow javascript files to be compiled. */
          // &quot;checkJs&quot;: true,                       /* Report errors in .js files. */
          // &quot;jsx&quot;: &quot;preserve&quot;,                     /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
          // &quot;declaration&quot;: true,                   /* Generates corresponding '.d.ts' file. */
          // &quot;declarationMap&quot;: true,                /* Generates a sourcemap for each corresponding '.d.ts' file. */
          // &quot;sourceMap&quot;: true,                     /* Generates corresponding '.map' file. */
          // &quot;outFile&quot;: &quot;./&quot;,                       /* Concatenate and emit output to single file. */
          // &quot;outDir&quot;: &quot;./&quot;,                        /* Redirect output structure to the directory. */
          // &quot;rootDir&quot;: &quot;./&quot;,                       /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
          // &quot;composite&quot;: true,                     /* Enable project compilation */
          // &quot;tsBuildInfoFile&quot;: &quot;./&quot;,               /* Specify file to store incremental compilation information */
          // &quot;removeComments&quot;: true,                /* Do not emit comments to output. */
          // &quot;noEmit&quot;: true,                        /* Do not emit outputs. */
          // &quot;importHelpers&quot;: true,                 /* Import emit helpers from 'tslib'. */
          // &quot;downlevelIteration&quot;: true,            /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
          // &quot;isolatedModules&quot;: true,               /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
      
          /* Strict Type-Checking Options */
          &quot;strict&quot;: true,                           /* Enable all strict type-checking options. */
          // &quot;noImplicitAny&quot;: true,                 /* Raise error on expressions and declarations with an implied 'any' type. */
          // &quot;strictNullChecks&quot;: true,              /* Enable strict null checks. */
          // &quot;strictFunctionTypes&quot;: true,           /* Enable strict checking of function types. */
          // &quot;strictBindCallApply&quot;: true,           /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
          // &quot;strictPropertyInitialization&quot;: true,  /* Enable strict checking of property initialization in classes. */
          // &quot;noImplicitThis&quot;: true,                /* Raise error on 'this' expressions with an implied 'any' type. */
          // &quot;alwaysStrict&quot;: true,                  /* Parse in strict mode and emit &quot;use strict&quot; for each source file. */
      
          /* Additional Checks */
          // &quot;noUnusedLocals&quot;: true,                /* Report errors on unused locals. */
          // &quot;noUnusedParameters&quot;: true,            /* Report errors on unused parameters. */
          // &quot;noImplicitReturns&quot;: true,             /* Report error when not all code paths in function return a value. */
          // &quot;noFallthroughCasesInSwitch&quot;: true,    /* Report errors for fallthrough cases in switch statement. */
      
          /* Module Resolution Options */
          // &quot;moduleResolution&quot;: &quot;node&quot;,            /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
          // &quot;baseUrl&quot;: &quot;./&quot;,                       /* Base directory to resolve non-absolute module names. */
          // &quot;paths&quot;: {},                           /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
          // &quot;rootDirs&quot;: [],                        /* List of root folders whose combined content represents the structure of the project at runtime. */
          // &quot;typeRoots&quot;: [],                       /* List of folders to include type definitions from. */
          // &quot;types&quot;: [],                           /* Type declaration files to be included in compilation. */
          // &quot;allowSyntheticDefaultImports&quot;: true,  /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
          &quot;esModuleInterop&quot;: true,                  /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
          // &quot;preserveSymlinks&quot;: true,              /* Do not resolve the real path of symlinks. */
          // &quot;allowUmdGlobalAccess&quot;: true,          /* Allow accessing UMD globals from modules. */
      
          /* Source Map Options */
          // &quot;sourceRoot&quot;: &quot;&quot;,                      /* Specify the location where debugger should locate TypeScript files instead of source locations. */
          // &quot;mapRoot&quot;: &quot;&quot;,                         /* Specify the location where debugger should locate map files instead of generated locations. */
          // &quot;inlineSourceMap&quot;: true,               /* Emit a single file with source maps instead of having a separate file. */
          // &quot;inlineSources&quot;: true,                 /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
      
          /* Experimental Options */
          // &quot;experimentalDecorators&quot;: true,        /* Enables experimental support for ES7 decorators. */
          // &quot;emitDecoratorMetadata&quot;: true,         /* Enables experimental support for emitting type metadata for decorators. */
      
          /* Advanced Options */
          &quot;skipLibCheck&quot;: true,                     /* Skip type checking of declaration files. */
          &quot;forceConsistentCasingInFileNames&quot;: true  /* Disallow inconsistently-cased references to the same file. */
        }
      }
  
  </code></pre>
  <p>EDIT 2:
  Changed tsconfig.json
  <code>&quot;allowSyntheticDefaultImports&quot;: true</code>
  Still showing the same error</p>
  <p>EDIT 3:
  Github link: [REMOVED]</p>
  <p>the problem is on <code>./server</code>
  <code>./server2</code> is working just fine. Same configs.</p>
  <p>EDIT4: RESOLVED</p>
  <p>According to your GitHub repo, ./server does NOT have a tsconfig file while .server2 does have one.. If I need to be more clear: they do not have the same config, because server does not even have a config. You should move ./server/src/tsconfig.json to ./server/tsconfig.json, just like your tsconfig file is in ./server2 (notice I said MOVE not COPY the tsconfig).. – <a href="https://stackoverflow.com/users/10431732/matt-oestreich">Matt Oestreich</a></p>