title: ECMAscript export in Node.js
body: <p>Im creating an NFL football simulator in nodejs and am having trouble exporting one of my variables.  As you can see in my get_teams.js i make many HTTP requests.  I then process the responseArr and format the data.  Where I am running into an issue is when I try and export the sorted_teams_array.  you can find this code at the very bottom of get_teams.js.</p>
  <p>I then try and import this array into tester.js and console log it.  I will eventually use this file to inject a mongo database with the array, but for now am just trying to console log it and cannot get it to work.  I am using the --experimental-modules in my npm scripts when I run npm run tester, and still nothing.  Any help would be great!  I am a noobie so please no hate!</p>
  <h2>get_teams.js</h2>
  <pre><code>import axios from 'axios';
  import Nfl_team from '../models/teamModel.js';
  import Offensive_stats from '../models/offensiveStatsModel.js';
  import Defensive_stats from '../models/defensiveStatsModel.js';
  import Game_stats from '../models/gameStatsModel.js';
  import colors from 'colors';
  import dotenv from 'dotenv';
  dotenv.config();
  
  const teams = {};
  
  
  
  function get_teams() {
    axios.all([
      axios.get(`https://api.sportsdata.io/api/nfl/fantasy/json/Standings/${process.env.SEASON}?key=${process.env.API_KEY}`),
  
      // ... many more gets
  
    ])
    .then(function (responseArr) {
        
      responseArr[0].data.forEach(element =&gt; {
          teams[element.Team] = new Nfl_team(element.Team, element.Name, element.Wins, element.Losses, element.Ties,
            element.Percentage, element.DivisionWins, element.DivisionLosses, element.DivisionTies,
            element.PointsFor, element.PointsAgainst)
      });
  
      // many more forEach blocks on responseArr[1, 2, 3...]
      
      /* power rating algorithm logic
      _____________________________________________ */
      
     const teams_array = Object.entries(teams);
  
     export const sorted_teams_array = teams_array.sort((a, b) =&gt; {
        if (a[1].average_victory_margin &gt; b[1].average_victory_margin) return -1;
        if (a[1].average_victory_margin &lt; b[1].average_victory_margin) return 1;
        return 0;
      })
  
      console.log(sorted_teams_array);
  
      teams_array.forEach(element =&gt; {
        console.log(`average victory margin for ${element[0]} = ${element[1].average_victory_margin}`)
      });  
  
    })
    .catch(function (error) {
      // handle error
      console.log(error);
    })
  }
  
  
  get_teams();
  
  </code></pre>
  <h2>tester.js</h2>
  <pre><code>import { sorted_teams_array } from './get_teams';
  
  console.log(sorted_teams_array);
  
  
  /// returns
  (node:58769) ExperimentalWarning: The ESM module loader is experimental.
  internal/modules/esm/resolve.js:61
    let url = moduleWrapResolve(specifier, parentURL);
              ^
  
  Error: Cannot find module /Users/jojovera/Documents/nflSIMULATION/teams/get_teams imported from /Users/jojovera/Documents/nflSIMULATION/teams/tester.js
      at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:61:13)
      at Loader.resolve (internal/modules/esm/loader.js:94:40)
      at Loader.getModuleJob (internal/modules/esm/loader.js:240:28)
      at ModuleWrap.&lt;anonymous&gt; (internal/modules/esm/module_job.js:42:40)
      at link (internal/modules/esm/module_job.js:41:36) {
    code: 'ERR_MODULE_NOT_FOUND'
  }
  
  </code></pre>
  <h2>package.json</h2>
  <pre><code>{
    &quot;name&quot;: &quot;optionsscript&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;app.js&quot;,
    &quot;type&quot;: &quot;module&quot;,
    &quot;scripts&quot;: {
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;,
      &quot;start&quot;: &quot;node --experimental-modules app.js&quot;,
      &quot;afc_west&quot;: &quot;node --experimental-modules ../nflSIMULATION/teams/afc_west.js&quot;,
      &quot;get_teams&quot;: &quot;node --experimental-modules ../nflSIMULATION/teams/get_teams.js&quot;,
      &quot;tester&quot;: &quot;node --experimental-modules ../nflSIMULATION/teams/tester.js&quot;,
      &quot;get_offensive_stats&quot;: &quot;node --experimental-modules ../nflSIMULATION/teams/get_offensive_stats.js&quot;,
      &quot;get_defensive_stats&quot;: &quot;node --experimental-modules ../nflSIMULATION/teams/get_defensive_stats.js&quot;,
      &quot;get_victory_margin&quot;: &quot;node --experimental-modules ../nflSIMULATION/teams/get_victory_margin.js&quot;,
      &quot;power_rank&quot;: &quot;node --experimental-modules ../nflSIMULATION/teams/power_rank.js&quot;
    },
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;dependencies&quot;: {
      &quot;axios&quot;: &quot;^0.21.0&quot;,
      &quot;cheerio&quot;: &quot;^1.0.0-rc.5&quot;,
      &quot;colors&quot;: &quot;^1.4.0&quot;,
      &quot;dotenv&quot;: &quot;^8.2.0&quot;,
      &quot;express&quot;: &quot;^4.17.1&quot;,
      &quot;jsonwebtoken&quot;: &quot;^8.5.1&quot;,
      &quot;nodemon&quot;: &quot;^2.0.6&quot;,
      &quot;stats-lite&quot;: &quot;^2.2.0&quot;,
      &quot;terminal-kit&quot;: &quot;^1.44.0&quot;,
      &quot;tofixed&quot;: &quot;^1.0.0&quot;
    }
  }
  
  </code></pre>