title: Typescript and Node.js error "SyntaxError: Cannot use import statement outside a module"
body: <p>After running rpm run start, an error gets printed: SyntaxError: Cannot use import statement outside a module.
  NOTE: I'm using this with GCP Cloud Run.</p>
  <p>package.json</p>
  <pre><code> {
    &quot;name&quot;: &quot;auth-api-public&quot;,
    &quot;version&quot;: &quot;0.0.1&quot;,
    &quot;main&quot;: &quot;src/index.ts&quot;,
    &quot;type&quot;: &quot;module&quot;,
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;node src/index.ts&quot;,
      &quot;lint&quot;: &quot;eslint src/**.ts&quot;,
      &quot;fix&quot;: &quot;eslint --fix *.ts&quot;
    },
    &quot;author&quot;: &quot;Jacob Miller&quot;,
    &quot;engines&quot;: {
      &quot;node&quot;: &quot;&gt;=12.0.0&quot;
    },
    &quot;dependencies&quot;: {
      &quot;@google-cloud/secret-manager&quot;: &quot;^3.9.0&quot;,
      &quot;express&quot;: &quot;^4.17.1&quot;,
      &quot;firebase-admin&quot;: &quot;^9.11.0&quot;,
      &quot;stytch&quot;: &quot;^3.0.2&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@typescript-eslint/eslint-plugin&quot;: &quot;^3.9.1&quot;,
      &quot;@typescript-eslint/parser&quot;: &quot;^3.8.0&quot;,
      &quot;eslint&quot;: &quot;^7.30.0&quot;,
      &quot;eslint-config-google&quot;: &quot;^0.14.0&quot;,
      &quot;eslint-config-prettier&quot;: &quot;8.3.0&quot;,
      &quot;eslint-plugin-import&quot;: &quot;^2.23.4&quot;,
      &quot;eslint-plugin-node&quot;: &quot;11.1.0&quot;,
      &quot;eslint-plugin-promise&quot;: &quot;5.1.0&quot;
    }
  }
  </code></pre>
  <p>Then I have a folder named src with the file containing the import statements in index.ts (see screenshot with file structure).
  <a href="https://i.stack.imgur.com/7PznB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7PznB.png" alt="File Structure" /></a></p>
  <p>This is the import statement code:</p>
  <pre><code>import * as express from &quot;express&quot;;
  import * as stytch from &quot;stytch&quot;;
  import * as admin from &quot;firebase-admin&quot;;
  </code></pre>
  <p>This is the tsconfig.json:</p>
  <pre><code>    {
    &quot;compilerOptions&quot;: {
      &quot;target&quot;: &quot;es5&quot;,
      &quot;module&quot;: &quot;commonjs&quot;,
      &quot;declaration&quot;: true,
      &quot;outDir&quot;: &quot;./dist&quot;,
      &quot;strict&quot;: true,
      &quot;esModuleInterop&quot;: true,
      &quot;forceConsistentCasingInFileNames&quot;: true
    }
  }
  
      // {
      //   &quot;compilerOptions&quot;: {
      //     &quot;outDir&quot;: &quot;./built&quot;,
      //     &quot;allowJs&quot;: true,
      //     &quot;target&quot;: &quot;es6&quot;,
      //     &quot;noImplicitReturns&quot;: true,
      //     &quot;noUnusedLocals&quot;: true,
      //    &quot;moduleResolution&quot;: &quot;node&quot;,
      //     &quot;sourceMap&quot;: true,
      //     &quot;strict&quot;: false,
      //   },
      //   &quot;include&quot;: [&quot;src&quot;],
      //   &quot;compileOnSave&quot;: true,
      // }
  </code></pre>
  <p>Then the error message after running npm run start screenshot:
  <a href="https://i.stack.imgur.com/Sty5t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Sty5t.png" alt="Error" /></a></p>