I'm trying to import another .js file in my main server file "App.js", but I keep getting the syntax error:
SyntaxError:Cannot use import statement outside a module
I did include the "type": "module" in my package.json file.
You can see the line where I'm trying to import the file here;
import {Read as readSensor} from './Sensor.js';
The function that I'm trying to import looks like this:
export async function Read() {
const res = await fetch(SensorUrl);
if(res.ok){
return await res.json();
}
else{
throw new Error('Bad Reading');
}
}
AFAIK, the syntax of my import/exports is correct, so I really cannot figure out what I'm doing wrong.