hard an issue with parsing my node version indicates that its not a function so i uploaded it and renamed my file extension to .mjs and it worked perfectly #14
but issues keep on rising using newer versions of node as it doesnt support old js some help please i have been stuck for days but the majoe issuw is loading data on start up on the front end here is my planets.model.mjs
import path from 'path';
import fs from 'fs';
import { parse } from 'csv-parse';
const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(__filename);
export { loadPlanetsData };
export const planets = habitablePlanets; my server runs perfectly but when i run it in the browser on my localhost aam told i cannot get
but issues keep on rising using newer versions of node as it doesnt support old js some help please i have been stuck for days but the majoe issuw is loading data on start up on the front end here is my planets.model.mjs import path from 'path'; import fs from 'fs'; import { parse } from 'csv-parse';
const filename = new URL(import.meta.url).pathname; const dirname = path.dirname(__filename);
let habitablePlanets = [];
function isHabitablePlanet(planet) { return ( planet['koi_disposition'] === 'CONFIRMED' && planet['koi_insol'] > 0.36 && planet['koi_insol'] < 1.11 && planet['koi_prad'] < 1.6 ); }
async function loadPlanetsData() { return new Promise((resolve, reject) => { fs.createReadStream(path.join(__dirname, '..', '..', 'data', 'kepler_data.csv')) .pipe( parse({ comment: '#', columns: true, }) ) .on('data', (data) => { if (isHabitablePlanet(data)) { habitablePlanets.push(data); } }) .on('error', (err) => { console.log(err); reject(err); }) .on('end', () => { console.log(
${habitablePlanets.length} habitable planets found!
); resolve(); }); }); }export { loadPlanetsData }; export const planets = habitablePlanets; my server runs perfectly but when i run it in the browser on my localhost aam told i cannot get