I tried to link mathjs to my script but got this error:
GET http://localhost:3000/node_modules/mathjs net::ERR_ABORTED 404 (Not Found)
I use local node server
Server code:
const http = require("http");
const fs = require("fs");
http.createServer(function(request, response){
let filePath = request.url.substring(1);
if(filePath == "") filePath = "index.html";
fs.readFile(filePath, function(error, data){
if(error){
response.statusCode = 404;
response.end("Resourse not found!");
}
else{
if(filePath.endsWith(".js")) response.setHeader("Content-Type", "text/javascript");
response.end(data);
}
});
}).listen(3000, function(){
console.log("Server started at 3000");
});
My project strucutre:
I tried to correct path, but this didn’t help (path was correct?)
import {evaluate} from './node_modules/mathjs';