title: SyntaxError: Cannot use import statement outside a module when debugging Protractor Test in Visual Studio code
body: <p>I am trying to setup my protractor to do debugging using VS Code. And I'm following the steps on this <a href="https://medium.com/@ganeshsirsi/how-to-debug-protractor-tests-in-visual-studio-code-e945fc971a74" rel="nofollow noreferrer">page</a>.</p>
  <p>However, I came up with this error/issue when running F5.</p>
  <p><strong>ERROR</strong></p>
  <pre><code>E/configParser - protractor.config.ts:1
  import { Config, browser } from 'protractor';
  ^^^^^^
  
  SyntaxError: Cannot use import statement outside a module
      at wrapSafe (internal/modules/cjs/loader.js:979:16)
      at Module._compile (internal/modules/cjs/loader.js:1027:27)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
      at Module.load (internal/modules/cjs/loader.js:928:32)
      at Function.Module._load (internal/modules/cjs/loader.js:769:14)
      at Module.require (internal/modules/cjs/loader.js:952:19)
      at require (internal/modules/cjs/helpers.js:88:18)
  </code></pre>
  <hr />
  <h2>Code</h2>
  <p><strong>tsconfig.json</strong></p>
  <pre><code>{
    &quot;compileOnSave&quot;: true,
    &quot;compilerOptions&quot;: {
      &quot;target&quot;: &quot;es6&quot;,
      &quot;module&quot;: &quot;commonjs&quot;,
      &quot;moduleResolution&quot;: &quot;node&quot;,
      &quot;declaration&quot;: false,
      &quot;removeComments&quot;: false,
      &quot;noImplicitAny&quot;: true,
      &quot;types&quot;: [&quot;jasmine&quot;, &quot;node&quot;],
      &quot;resolveJsonModule&quot;: true,
      &quot;outDir&quot;: &quot;./dist/out-tsc&quot;,
      &quot;mapRoot&quot;: &quot;./dist/out-tsc&quot;,
      &quot;sourceMap&quot;: true,
      &quot;emitDecoratorMetadata&quot;: true,
      &quot;experimentalDecorators&quot;: true,
      &quot;allowSyntheticDefaultImports&quot;: true,
      &quot;typeRoots&quot;: [
        &quot;node_modules/@types&quot;
      ]
    },
    &quot;exclude&quot;: [
      &quot;node_modules&quot;
    ]
  }
  </code></pre>
  <p><strong>launch.json</strong></p>
  <pre><code>{
  
      // Use IntelliSense to learn about possible attributes.
      // Hover to view descriptions of existing attributes.
      // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
      &quot;version&quot;: &quot;0.2.0&quot;,
      &quot;configurations&quot;: [
          {
              &quot;type&quot;: &quot;pwa-node&quot;,
              &quot;request&quot;: &quot;launch&quot;,
              &quot;name&quot;: &quot;Launch Program&quot;,
              &quot;program&quot;: &quot;${workspaceFolder}\\Protractor\\node_modules\\protractor\\bin\\protractor&quot;,
              &quot;args&quot;:[
                  &quot;${workspaceFolder}\\Protractor\\protractor.config.ts&quot;
              ],
              &quot;preLaunchTask&quot;: &quot;tsc: build - Protractor/tsconfig.json&quot;,
              &quot;outFiles&quot;: [
                  &quot;${workspaceFolder}/Protractor/dist/out-tsc/**/*.js&quot;
              ]
          }
      ]
  }
  </code></pre>
  <p><strong>protractor.config.ts</strong></p>
  <pre><code>import { Config, browser } from 'protractor';
  let BeautifulReporter:any, SpecReporter:any;
  
  export let config: Config = {
      framework: 'jasmine2',
      baseUrl: &quot;&quot;,
      exclude: ['node_modules/**/*spec.js'],
      directConnect : true,
  
      params : {
          //Insert needed params
      },
  
      jasmineNodeOpts: {
          // Default time to wait in ms before a test fails.
          defaultTimeoutInterval: 270000,
          // onComplete will be called just before the driver quits.
          onComplete: null,
          // If true, display spec names.
          isVerbose: true,
          // If true, print colors to the terminal.
          showColors: true,
          // If true, include stack traces in failures.
          includeStackTrace: true,
          //If you set it to true it would not fail the whole test run, but it would show errors in a real time - immediately after happening
          realtimeFailure: true,
          print:()=&gt;{}
      },
  
      //This capabilities is used for multiple browser testing
      capabilities: {
          'browserName': 'chrome',
          'platform': 'ANY',
          'version': 'ANY',
          'chromeOptions': {
              // disable &quot;chrome is being controlled by automated software&quot;
              &quot;excludeSwitches&quot;: [ &quot;enable-automation&quot; ],
              &quot;useAutomationExtension&quot;: false,
              'args': ['disable-infobars=true', &quot;--log-level=3&quot;, &quot;--headless&quot;, &quot;--window-size=1366x768&quot;],
              w3c: false,
              prefs: {
                  download : {
                      //'prompt_for_download': false,
                      //All downloading file will get downloaded at below location in folder fileDownload
                      'default_directory': __dirname + '\\downloadedfile'
                  },
                  'credentials_enable_service': false
              }
          }
      },
  
      beforeLaunch: () =&gt;{
          
          require('ts-node').register({
              project: require('path').join(__dirname, './tsconfig.json')
            });
      
          BeautifulReporter = require('protractor-beautiful-reporter');
          SpecReporter = require('jasmine-spec-reporter').SpecReporter;
          BeautifulReporter = new BeautifulReporter({
              baseDirectory: 'reports/beautiful'
              , clientDefaults: {
                  showTotalDurationIn: &quot;belowHeader&quot;,
                  totalDurationFormat: &quot;hms&quot;,
  
                  columnSettings: {
                      displayTime: true,
                      displayBrowser: false,
                      displaySessionId: false,
                      displayOS: false,
                      //inlineScreenshots:false
                  }
              },
              preserveDirectory: false,
              takeScreenShotsOnlyForFailedSpecs: true,
              jsonsSubfolder: 'jsons',
              screenshotsSubfolder: 'images',
              docName: 'test.html',
              docTitle: 'test'
          });
           
      },
  
      onPrepare: () =&gt; {
          let globals:any = global;
          globals.dvr = browser.driver;
          globals.EC = browser.ExpectedConditions;
          globals.baseDir = __dirname;
          browser.manage().window().maximize();
          browser.manage().timeouts().setScriptTimeout(125000);
          //Clean up existing downloaded file in folder downloadedfile
          const fsExtra = require('fs-extra');
          fsExtra.emptyDirSync(__dirname + &quot;/downloadedfile&quot;);
  
          jasmine.getEnv().addReporter(BeautifulReporter.getJasmine2Reporter());
          jasmine.getEnv().addReporter(new SpecReporter({
              spec: {displayStacktrace: true}
          }));
          
      },
  
  
      afterLaunch: () =&gt; {}
  
  };
  </code></pre>
  <p><strong>package.json</strong></p>
  <pre><code>{
    &quot;name&quot;: &quot;protractor&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;dependencies&quot;: {
      &quot;@types/oracledb&quot;: &quot;^5.1.0&quot;,
      &quot;jasmine-custom-message&quot;: &quot;^0.8.2&quot;,
      &quot;jasmine2-custom-message&quot;: &quot;^0.9.3&quot;,
      &quot;runtypes&quot;: &quot;^5.0.1&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@types/jasmine&quot;: &quot;^3.5.14&quot;,
      &quot;@types/node&quot;: &quot;^14.11.2&quot;,
      &quot;bluebird&quot;: &quot;^3.7.2&quot;,
      &quot;date-and-time&quot;: &quot;^0.14.2&quot;,
      &quot;jasmine-spec-reporter&quot;: &quot;^4.2.1&quot;,
      &quot;latest-version&quot;: &quot;^3.1.0&quot;,
      &quot;minimatch&quot;: &quot;^3.0.4&quot;,
      &quot;minimist&quot;: &quot;^1.2.5&quot;,
      &quot;oracledb&quot;: &quot;^4.2.0&quot;,
      &quot;protractor&quot;: &quot;^7.0.0&quot;,
      &quot;protractor-beautiful-reporter&quot;: &quot;^1.3.6&quot;,
      &quot;protractor-console-plugin&quot;: &quot;^0.1.1&quot;,
      &quot;protractor-istanbul-plugin&quot;: &quot;2.0.0&quot;,
      &quot;protractor-jasmine2-screenshot-reporter&quot;: &quot;^0.5.0&quot;,
      &quot;randomstring&quot;: &quot;^1.1.5&quot;,
      &quot;request&quot;: &quot;^2.88.2&quot;,
      &quot;testrail-api&quot;: &quot;^1.3.6&quot;,
      &quot;ts-node&quot;: &quot;^9.0.0&quot;,
      &quot;typescript&quot;: &quot;^4.0.3&quot;
    },
    &quot;resolutions&quot;: {
      &quot;yargs-parser&quot;: &quot;^18.1.2&quot;,
      &quot;minimist&quot;: &quot;1.2.3&quot;
    },
    &quot;scripts&quot;: {
      &quot;startSE&quot;: &quot;node node_modules/protractor/bin/webdriver-manager start&quot;,
      &quot;setup&quot;: &quot;npm install &amp;&amp; node node_modules/protractor/bin/webdriver-manager update&quot;,
      &quot;webdriver-manager-update&quot;: &quot;node node_modules/protractor/bin/webdriver-manager update&quot;,
      &quot;webdriver-manager-start&quot;: &quot;node node_modules/protractor/bin/webdriver-manager start --versions.standalone=3.141.59&quot;,
      &quot;version&quot;: &quot;protractor --version&quot;
    },
    &quot;repository&quot;: {
      &quot;type&quot;: &quot;git&quot;
    },
    &quot;type&quot;: &quot;module&quot;
  }
  </code></pre>
  <hr />
  <p>Tried the solution on this question <a href="https://stackoverflow.com/questions/61151108/protractor-typescript-es6-syntaxerror-cannot-use-import-statement-outside">Protractor / Typescript (es6): SyntaxError: Cannot use import statement outside a module</a> but no luck.</p>