title: Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (3:0)
body: <p>Hi I'm having this issue building a Nextjs application since yesterday. I didn't made any change at this level. I have reverted changes and the error persist.</p>
  <p>Could someone help me with that please?</p>
  <hr />
  <pre class="lang-html prettyprint-override"><code>./node_modules/typeorm/browser/index.js
  Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (3:0)
  You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders  
  | /*!
  |  */
  &gt; import &quot;reflect-metadata&quot;;
  | // -------------------------------------------------------------------------
  | // Commonly Used exports
  
  Import trace for requested module:
  ./node_modules/typeorm/index.mjs
  </code></pre>
  
  <hr />
  <p>This is my package.json:</p>
  <ul>
  <li>I have some babel dependencies, but I don't have any .babelrc file configured, it was used for loader testing as the error message suggest, but no luck with that.</li>
  </ul>
  <pre class="lang-html prettyprint-override"><code>{
    &quot;private&quot;: true,
    &quot;scripts&quot;: {
      &quot;dev&quot;: &quot;next&quot;,
      &quot;build&quot;: &quot;next build&quot;,
      &quot;start&quot;: &quot;next start&quot;,
      &quot;test&quot;: &quot;jest --setupFiles=dotenv/config&quot;,
      &quot;lint&quot;: &quot;eslint pages --ext .ts,.tsx&quot;
    },
    &quot;dependencies&quot;: {
      &quot;@babel/core&quot;: &quot;^7.17.5&quot;,
      &quot;@babel/plugin-proposal-decorators&quot;: &quot;^7.17.2&quot;,
      &quot;@babel/plugin-proposal-private-methods&quot;: &quot;^7.16.11&quot;,
      &quot;@emotion/react&quot;: &quot;^11.7.1&quot;,
      &quot;@emotion/styled&quot;: &quot;^11.6.0&quot;,
      &quot;@mui/icons-material&quot;: &quot;^5.3.0&quot;,
      &quot;@mui/material&quot;: &quot;^5.3.0&quot;,
      &quot;@nivo/core&quot;: &quot;0.74.0&quot;,
      &quot;@nivo/line&quot;: &quot;^0.79.1&quot;,
      &quot;@types/js-cookie&quot;: &quot;^3.0.1&quot;,
      &quot;aos&quot;: &quot;^2.3.4&quot;,
      &quot;babel-plugin-transform-typescript-metadata&quot;: &quot;^0.3.2&quot;,
      &quot;bad-words&quot;: &quot;^3.0.4&quot;,
      &quot;clsx&quot;: &quot;^1.1.1&quot;,
      &quot;compressorjs&quot;: &quot;^1.1.1&quot;,
      &quot;date-and-time&quot;: &quot;^2.1.0&quot;,
      &quot;dotenv&quot;: &quot;^10.0.0&quot;,
      &quot;firebase&quot;: &quot;^9.6.2&quot;,
      &quot;google-maps-react&quot;: &quot;^2.0.2&quot;,
      &quot;js-cookie&quot;: &quot;^3.0.1&quot;,
      &quot;next&quot;: &quot;&gt;=12.0.9&quot;,
      &quot;react&quot;: &quot;^17.0.2&quot;,
      &quot;react-dom&quot;: &quot;^17.0.2&quot;,
      &quot;react-geocode&quot;: &quot;^0.2.3&quot;,
      &quot;react-loading-skeleton&quot;: &quot;^2.1.1&quot;,
      &quot;react-otp-input&quot;: &quot;^2.4.0&quot;,
      &quot;react-simple-star-rating&quot;: &quot;^4.0.5&quot;,
      &quot;reflect-metadata&quot;: &quot;^0.1.13&quot;,
      &quot;sass&quot;: &quot;^1.49.0&quot;,
      &quot;serverless-mysql&quot;: &quot;^1.5.4&quot;,
      &quot;swr&quot;: &quot;^1.2.1&quot;,
      &quot;typeorm&quot;: &quot;^0.2.41&quot;,
      &quot;uuid&quot;: &quot;^8.3.2&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@types/jest&quot;: &quot;^27.4.0&quot;,
      &quot;@types/node&quot;: &quot;^17.0.18&quot;,
      &quot;@types/react&quot;: &quot;^16.9.55&quot;,
      &quot;@typescript-eslint/eslint-plugin&quot;: &quot;^5.9.1&quot;,
      &quot;@typescript-eslint/parser&quot;: &quot;^5.9.1&quot;,
      &quot;eslint&quot;: &quot;^7.32.0&quot;,
      &quot;eslint-config-standard&quot;: &quot;^16.0.3&quot;,
      &quot;eslint-plugin-import&quot;: &quot;^2.25.4&quot;,
      &quot;eslint-plugin-node&quot;: &quot;^11.1.0&quot;,
      &quot;eslint-plugin-promise&quot;: &quot;^5.2.0&quot;,
      &quot;eslint-plugin-react&quot;: &quot;^7.28.0&quot;,
      &quot;isomorphic-fetch&quot;: &quot;^3.0.0&quot;,
      &quot;jest&quot;: &quot;^27.4.7&quot;,
      &quot;node-fetch&quot;: &quot;&gt;=2.6.7&quot;,
      &quot;postcss&quot;: &quot;&gt;=8.2.13&quot;,
      &quot;postcss-flexbugs-fixes&quot;: &quot;^5.0.2&quot;,
      &quot;postcss-preset-env&quot;: &quot;^7.3.1&quot;,
      &quot;tailwindcss&quot;: &quot;^1.7.4&quot;,
      &quot;ts-jest&quot;: &quot;^27.1.3&quot;,
      &quot;ts-node&quot;: &quot;^10.4.0&quot;,
      &quot;typescript&quot;: &quot;^4.0.5&quot;
    },
    &quot;version&quot;: &quot;0.0.0&quot;
  }
  </code></pre>
  
  <p>This is my tsconfig.json:</p>
  <pre class="lang-html prettyprint-override"><code>{
      &quot;compilerOptions&quot;: {
        &quot;experimentalDecorators&quot;: true,
        &quot;baseUrl&quot;: &quot;.&quot;,
        &quot;paths&quot;: {
          &quot;@/components/*&quot;: [
            &quot;components/*&quot;
          ],
          &quot;@/lib/*&quot;: [
            &quot;lib/*&quot;
          ],
          &quot;@/entities/*&quot;: [
            &quot;entities/*&quot;
          ],
          &quot;@/services/*&quot;: [
            &quot;services/*&quot;
          ]
        },
        &quot;target&quot;: &quot;es5&quot;,
        &quot;lib&quot;: [
          &quot;dom&quot;,
          &quot;dom.iterable&quot;,
          &quot;esnext&quot;
        ],
        &quot;allowJs&quot;: true,
        &quot;skipLibCheck&quot;: true,
        &quot;strict&quot;: false,
        &quot;forceConsistentCasingInFileNames&quot;: true,
        &quot;noEmit&quot;: true,
        &quot;esModuleInterop&quot;: true,
        &quot;module&quot;: &quot;esnext&quot;,
        &quot;moduleResolution&quot;: &quot;node&quot;,
        &quot;resolveJsonModule&quot;: true,
        &quot;isolatedModules&quot;: true,
        &quot;jsx&quot;: &quot;preserve&quot;,
        &quot;incremental&quot;: true,
        &quot;types&quot;: [
          &quot;jest&quot;,
          &quot;node&quot;
        ]
      },
      &quot;include&quot;: [
        &quot;next-env.d.ts&quot;,
        &quot;**/*.ts&quot;,
        &quot;**/*.tsx&quot;
      ],
      &quot;exclude&quot;: [
        &quot;node_modules&quot;,
        &quot;functions&quot;
      ]
  }
  </code></pre>
  
  <p>Also I am importing typeorm not typeorm/browser as you can see:</p>
  <pre class="lang-html prettyprint-override"><code>import { User } from '@/entities/User'
  import 'reflect-metadata'
  import { Connection, createConnection } from 'typeorm'
  
  export async function initializeDatabase () {
    return new Promise&lt;Connection&gt;((resolve, reject) =&gt; {
      createConnection({
        type: 'mysql',
        host: process.env.MYSQL_HOST,
        port: parseInt(process.env.MYSQL_PORT),
        username: process.env.MYSQL_USERNAME,
        password: process.env.MYSQL_PASSWORD,
        database: process.env.MYSQL_DATABASE,
        entities: [
          User
        ],
        synchronize: true
      }).then(connection =&gt; {
        resolve(connection)
      }).catch(error =&gt; {
        reject(error)
      })
    })
  }
  </code></pre>