I am trying to import modules from tensorflowjs, and below is my code.
test.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title
</head>
<body>
<script type="module" src="./test.js"></script>
</body>
</html>
test.js
import * as tf from "./node_modules/@tensorflow/tfjs";
import {loadGraphModel} from "./node_modules/@tensorflow/tfjs-converter";
const MODEL_URL = './model.json';
const model = await loadGraphModel(MODEL_URL);
const cat = document.getElementById('cat');
model.execute(tf.browser.fromPixels(cat));
Besides, I run the server using python -m http.server
in my command prompt(Windows 10), and this is the error prompt in the console log of my browser:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
Can anyone help to solve this? Thank you