title: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/sync' is not defined by "exports" in node_modules\csv-parse\package.json
body: <p>Whenever I run index.js in nodejs I get this error message.</p>
  <pre><code>Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/sync' is not defined by &quot;exports&quot; in D:\Scuola\5f_Informatca\Tpsit\Telegram\node_modules\csv-parse\package.json  
      at new NodeError (node:internal/errors:371:5)
      at throwExportsNotFound (node:internal/modules/esm/resolve:453:9)
      at packageExportsResolve (node:internal/modules/esm/resolve:729:3)
      at resolveExports (node:internal/modules/cjs/loader:482:36)
      at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
      at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
      at Function.Module._load (node:internal/modules/cjs/loader:778:27)
      at Module.require (node:internal/modules/cjs/loader:1005:19)
      at require (node:internal/modules/cjs/helpers:102:18)
      at Object.&lt;anonymous&gt; (D:\Scuola\5f_Informatca\Tpsit\Telegram\node_modules\prettytable\prettytable.js:1:13)
      at Module._compile (node:internal/modules/cjs/loader:1103:14)
      at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
      at Module.load (node:internal/modules/cjs/loader:981:32)
      at Function.Module._load (node:internal/modules/cjs/loader:822:12)
      at Module.require (node:internal/modules/cjs/loader:1005:19)
      at require (node:internal/modules/cjs/helpers:102:18)
      at Object.&lt;anonymous&gt; (D:\Scuola\5f_Informatca\Tpsit\Telegram\index.js:3:21)
      at Module._compile (node:internal/modules/cjs/loader:1103:14)
      at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
      at Module.load (node:internal/modules/cjs/loader:981:32)
      at Function.Module._load (node:internal/modules/cjs/loader:822:12)
      at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
    code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
  }
  </code></pre>
  <p>This error only comes up when I try to add this line of code</p>
  <p><code>const PrettyTable = require('prettytable');</code></p>
  <p>I'm creating a bot, and I would like to send a message in tabular form but when I try to add require('pretty table') if gives me the error above.</p>
  <p>Things I've tried:
  Installed prettytable with npm,
  Deleted node_modules and reinstalled every package,
  Run npm update
  But nothing has worked.</p>
  <p>Here is the node_modules\csv-parse\package.json file for reference</p>
  <pre><code>{
    &quot;version&quot;: &quot;5.0.4&quot;,
    &quot;name&quot;: &quot;csv-parse&quot;,
    &quot;description&quot;: &quot;CSV parsing implementing the Node.js `stream.Transform` API&quot;,
    &quot;keywords&quot;: [
      &quot;csv&quot;,
      &quot;parse&quot;,
      &quot;parser&quot;,
      &quot;convert&quot;,
      &quot;tsv&quot;,
      &quot;stream&quot;
    ],
    &quot;author&quot;: &quot;David Worms &lt;david@adaltas.com&gt; (https://www.adaltas.com)&quot;,
    &quot;contributors&quot;: [
      &quot;David Worms &lt;david@adaltas.com&gt; (https://www.adaltas.com)&quot;,
      &quot;Will White (https://github.com/willwhite)&quot;,
      &quot;Justin Latimer (https://github.com/justinlatimer)&quot;,
      &quot;jonseymour (https://github.com/jonseymour)&quot;,
      &quot;pascalopitz (https://github.com/pascalopitz)&quot;,
      &quot;Josh Pschorr (https://github.com/jpschorr)&quot;,
      &quot;Elad Ben-Israel (https://github.com/eladb)&quot;,
      &quot;Philippe Plantier (https://github.com/phipla)&quot;,
      &quot;Tim Oxley (https://github.com/timoxley)&quot;,
      &quot;Damon Oehlman (https://github.com/DamonOehlman)&quot;,
      &quot;Alexandru Topliceanu (https://github.com/topliceanu)&quot;,
      &quot;Visup (https://github.com/visup)&quot;,
      &quot;Edmund von der Burg (https://github.com/evdb)&quot;,
      &quot;Douglas Christopher Wilson (https://github.com/dougwilson)&quot;,
      &quot;Joe Eaves (https://github.com/Joeasaurus)&quot;,
      &quot;Mark Stosberg (https://github.com/markstos)&quot;
    ],
    &quot;exports&quot;: {
      &quot;.&quot;: {
        &quot;import&quot;: &quot;./lib/index.js&quot;,
        &quot;require&quot;: &quot;./dist/cjs/index.cjs&quot;
      },
      &quot;./sync&quot;: {
        &quot;import&quot;: &quot;./lib/sync.js&quot;,
        &quot;require&quot;: &quot;./dist/cjs/sync.cjs&quot;
      },
      &quot;./browser/esm&quot;: &quot;./dist/esm/index.js&quot;,
      &quot;./browser/esm/sync&quot;: &quot;./dist/esm/sync.js&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@rollup/plugin-eslint&quot;: &quot;^8.0.1&quot;,
      &quot;@rollup/plugin-node-resolve&quot;: &quot;^13.0.6&quot;,
      &quot;@types/mocha&quot;: &quot;^9.0.0&quot;,
      &quot;@types/node&quot;: &quot;^16.11.7&quot;,
      &quot;coffeelint&quot;: &quot;^2.1.0&quot;,
      &quot;coffeescript&quot;: &quot;^2.6.1&quot;,
      &quot;csv-generate&quot;: &quot;^4.0.4&quot;,
      &quot;csv-spectrum&quot;: &quot;^1.0.0&quot;,
      &quot;each&quot;: &quot;^1.2.2&quot;,
      &quot;eslint&quot;: &quot;^8.2.0&quot;,
      &quot;mocha&quot;: &quot;^9.1.3&quot;,
      &quot;pad&quot;: &quot;^3.2.0&quot;,
      &quot;rollup&quot;: &quot;^2.60.0&quot;,
      &quot;rollup-plugin-node-builtins&quot;: &quot;^2.1.2&quot;,
      &quot;rollup-plugin-node-globals&quot;: &quot;^1.4.0&quot;,
      &quot;should&quot;: &quot;^13.2.3&quot;,
      &quot;stream-transform&quot;: &quot;^3.0.4&quot;,
      &quot;ts-node&quot;: &quot;^10.4.0&quot;,
      &quot;typescript&quot;: &quot;^4.4.4&quot;
    },
    &quot;files&quot;: [
      &quot;dist&quot;,
      &quot;lib&quot;
    ],
    &quot;homepage&quot;: &quot;https://csv.js.org/parse/&quot;,
    &quot;license&quot;: &quot;MIT&quot;,
    &quot;main&quot;: &quot;./dist/cjs/index.cjs&quot;,
    &quot;mocha&quot;: {
      &quot;inline-diffs&quot;: true,
      &quot;loader&quot;: &quot;./test/loaders/all.mjs&quot;,
      &quot;recursive&quot;: true,
      &quot;reporter&quot;: &quot;spec&quot;,
      &quot;require&quot;: [
        &quot;should&quot;
      ],
      &quot;throw-deprecation&quot;: true,
      &quot;timeout&quot;: 40000
    },
    &quot;repository&quot;: {
      &quot;type&quot;: &quot;git&quot;,
      &quot;url&quot;: &quot;https://github.com/adaltas/node-csv.git&quot;,
      &quot;directory&quot;: &quot;packages/csv-parse&quot;
    },
    &quot;scripts&quot;: {
      &quot;build&quot;: &quot;npm run build:rollup &amp;&amp; npm run build:ts&quot;,
      &quot;build:rollup&quot;: &quot;npx rollup -c&quot;,
      &quot;build:ts&quot;: &quot;cp lib/*.ts dist/cjs &amp;&amp; cp lib/*.ts dist/esm&quot;,
      &quot;lint&quot;: &quot;npm run lint:lib &amp;&amp; npm run lint:samples &amp;&amp; npm run lint:test&quot;,
      &quot;lint:lib&quot;: &quot;eslint --fix lib/*.js&quot;,
      &quot;lint:samples&quot;: &quot;eslint --fix samples/*.js&quot;,
      &quot;lint:test&quot;: &quot;coffeelint --fix test/*.coffee&quot;,
      &quot;preversion&quot;: &quot;npm run build &amp;&amp; git add dist&quot;,
      &quot;pretest&quot;: &quot;npm run build&quot;,
      &quot;test&quot;: &quot;mocha 'test/**/*.{coffee,ts}'&quot;,
      &quot;test:legacy&quot;: &quot;mocha --loader=./test/loaders/legacy/all.mjs 'test/**/*.{coffee,ts}'&quot;
    },
    &quot;type&quot;: &quot;module&quot;,
    &quot;types&quot;: &quot;dist/esm/index.d.ts&quot;,
    &quot;typesVersions&quot;: {
      &quot;*&quot;: {
        &quot;.&quot;: [
          &quot;dist/esm/index.d.ts&quot;
        ],
        &quot;sync&quot;: [
          &quot;dist/esm/sync.d.ts&quot;
        ],
        &quot;browser/esm&quot;: [
          &quot;dist/esm/index.d.ts&quot;
        ],
        &quot;browser/esm/sync&quot;: [
          &quot;dist/esm/sync.d.ts&quot;
        ]
      }
    },
    &quot;gitHead&quot;: &quot;bab8d89a6eb3bc073233e27b7af0a50284b1590f&quot;
  }
  </code></pre>
  <p>And here is the prettytable\prettytable.js file</p>
  <pre><code>var parse = require('csv-parse/lib/sync');
  var fs = require('fs');
  
  var PrettyTable = function () {
      // Skeleton structure of table with list of column names, row and max width of each column element
      this.table = {
          'columnNames': [],
          'rows': [],
          'maxWidth': []
      };
      this.version = '0.3.1';
  };
  
  // Define list of columns for the table
  PrettyTable.prototype.fieldNames = function (names) {
      this.table.columnNames = names;
      for (var i = 0; i &lt; names.length; i++) {
          this.table.maxWidth.push(names[i].length);
      }
  };
  
  // Add a single row to the table
  PrettyTable.prototype.addRow = function (row) {
      this.table.rows.push(row);
      for (var i = 0; i &lt; row.length; i++) {
          if (row[i].toString().length &gt; this.table.maxWidth[i]) {
              this.table.maxWidth[i] = row[i].toString().length;
          }
      }
  };
  
  // Single function to create table when headers and array of rows passed
  PrettyTable.prototype.create = function (headers, rows) {
      // Add table headers
      this.fieldNames(headers);
  
      // Add rows one by one
      for (var i = 0; i &lt; rows.length; i++) {
          this.addRow(rows[i]);
      }
  };
  
  // Convert the table to string
  PrettyTable.prototype.toString = function () {
      var finalTable = '';
      var columnString = '| ';
      var rowString = '';
      var lengthDifference = '';
  
      // Draw a line based on the max width of each column and return
      var drawLine = function (table) {
          var finalLine = '+';
          for (var i = 0; i &lt; table.maxWidth.length; i++) {
              finalLine += Array(table.maxWidth[i] + 3).join('-') + '+';
          }
          return finalLine;
      };
  
      // If no columns present, return empty string
      if (this.table.columnNames.length === 0) {
          return finalTable;
      }
  
      // Create the table header from column list
      for (var i = 0; i &lt; this.table.columnNames.length; i++) {
          columnString += this.table.columnNames[i];
          // Adjust for max width of the column and pad spaces
          if (this.table.columnNames[i].length &lt; this.table.maxWidth[i]) {
              lengthDifference = this.table.maxWidth[i] - this.table.columnNames[i].length;
              columnString += Array(lengthDifference + 1).join(' ');
          }
          columnString += ' | ';
      }
      finalTable += drawLine(this.table) + '\n';
      finalTable += columnString + '\n';
      finalTable += drawLine(this.table) + '\n';
  
      // Construct the table body
      for (i = 0; i &lt; this.table.rows.length; i++) {
          var tempRowString = '| ';
          for (var k = 0; k &lt; this.table.rows[i].length; k++) {
              tempRowString += this.table.rows[i][k];
              // Adjust max width of each cell and pad spaces as necessary
              if (this.table.rows[i][k].toString().length &lt; this.table.maxWidth[k]) {
                  lengthDifference = this.table.maxWidth[k] - this.table.rows[i][k].toString().length;
                  tempRowString += Array(lengthDifference + 1).join(' ');
              }
              tempRowString += ' | ';
          }
          rowString += tempRowString + '\n';
      }
      // Remove newline from the end of the table string
      rowString = rowString.slice(0, -1);
      // Append to the final table string
      finalTable += rowString + '\n';
      // Draw last line and return
      finalTable += drawLine(this.table) + '\n';
      return finalTable;
  };
  
  // Write the table string to the console
  PrettyTable.prototype.print = function () {
      console.log(this.toString());
  };
  
  // Write the table string to the console as HTML table formats
  PrettyTable.prototype.html = function (attributes) {
      // If attributes provided, add them as inline properties, else create default table tag
      var htmlTable = '';
      if (typeof attributes == 'undefined') {
          htmlTable = '&lt;table&gt;';
      }
      else {
          var attributeList = [];
          for (var key in attributes) {
              attributeList.push(key + '=\'' + attributes[key] + '\'');
          }
          var attributeString = attributeList.join(' ');
          htmlTable = '&lt;table ' + attributeString + '&gt;';
      }
  
      // Define the table headers in &lt;thead&gt; from table column list
      var tableHead = '&lt;thead&gt;&lt;tr&gt;';
      for (var i = 0; i &lt; this.table.columnNames.length; i++) {
          var headerString = '&lt;th&gt;' + this.table.columnNames[i] + '&lt;/th&gt;';
          tableHead += headerString;
      }
      tableHead += '&lt;/tr&gt;&lt;/thead&gt;';
      htmlTable += tableHead;
  
      // Construct the table body from the array of rows
      var tableBody = '&lt;tbody&gt;';
      for (i = 0; i &lt; this.table.rows.length; i++) {
          var rowData = '&lt;tr&gt;';
          for (var k = 0; k &lt; this.table.rows[i].length; k++) {
              var cellData = '&lt;td&gt;' + this.table.rows[i][k] + '&lt;/td&gt;';
              rowData += cellData;
          }
          rowData += '&lt;/tr&gt;';
          tableBody += rowData;
      }
      // Close all tags and return
      tableBody += '&lt;/tbody&gt;';
      htmlTable += tableBody;
      htmlTable += '&lt;/table&gt;';
  
      return htmlTable;
  };
  
  // Create the table from a CSV file
  PrettyTable.prototype.csv = function (filename) {
      var csvdata = fs.readFileSync(filename, 'utf8');
      var records = parse(csvdata);
  
      var lineCounter = 0;
      for (var i = 0; i &lt; records.length; i++) {
          if (lineCounter === 0) {
              this.fieldNames(records[i]);
              lineCounter += 1;
          }
          else {
              this.addRow(records[i]);
              lineCounter += 1;
          }
      }
  };
  
  // Create the table from a JSON file
  PrettyTable.prototype.json = function (filename) {
      var rowKeys = '';
      var rowVals = '';
      var jsondata = JSON.parse(fs.readFileSync(filename, 'utf8'));
      for (var i = 0; i &lt; jsondata.length; i++) {
          rowKeys = Object.keys(jsondata[i]);
          rowVals = [];
          for (var k = 0; k &lt; rowKeys.length; k++) {
              rowVals.push(jsondata[i][rowKeys[k]]);
          }
          if (this.table.columnNames.length === 0) {
              this.fieldNames(rowKeys);
          }
          this.addRow(rowVals);
      }
  };
  
  // Sort the table given a column in ascending or descending order
  PrettyTable.prototype.sortTable = function (colname, reverse) {
      // Find the index of the column given the name
      var colindex = this.table.columnNames.indexOf(colname);
  
      // Comparator method which takes the column index and sort direction
      var Comparator = function ( a, b) {
          if (typeof reverse === 'boolean' &amp;&amp; reverse === true) {
              if (a[colindex] &lt; b[colindex]) {
                  return 1;
              }
              else if (a[colindex] &gt; b[colindex]) {
                  return -1;
              }
              else {
                  return 0;
              }
          }
          else {
              if (a[colindex] &lt; b[colindex]) {
                  return -1;
              }
              else if (a[colindex] &gt; b[colindex]) {
                  return 1;
              }
              else {
                  return 0;
              }
          }
      }
      // Sort array of table rows
      this.table.rows = this.table.rows.sort(Comparator);
  };
  
  // Delete a single row from the table given row number
  PrettyTable.prototype.deleteRow = function (rownum) {
      if (rownum &lt;= this.table.rows.length &amp;&amp; rownum &gt; 0) {
          this.table.rows.splice(rownum - 1, 1);
      }
  };
  
  // Clear the contents from the table, but keep columns and structure
  PrettyTable.prototype.clearTable = function () {
      this.table.rows = [];
  };
  
  // Delete the entire table
  PrettyTable.prototype.deleteTable = function () {
      this.table = {
          'columnNames': [],
          'rows': [],
          'maxWidth': []
      };
  };
  
  module.exports = PrettyTable;
  
  </code></pre>
  <p>I'm new to this so I would really appreciate all the help I can get, thank you.</p>