I want to import frappe by using the following code
import { Chart } from "frappe-charts/dist/frappe-charts.min.esm";
I already downloaded frappe-charts package and put it into my project package.
But it always shows: "Uncaught SyntaxError: Cannot use import statement outside a module"
Now I just solved this problem but a new problem appeared.
The problems are:
index.html:1 Access to script at 'file:///Users/dizitong/Downloads/2yp7jv/js/index.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.
index.html:7 GET file:///Users/dizitong/Downloads/2yp7jv/js/index.js net::ERR_FAILED
Here is index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Data Chart</title>
<script type="module" src="js/index.js"></script>
</head>
<body>
<div id="chart"></div>
<form id="municipality-form">
<input type="text" id="input-area" placeholder="Type municipality name" />
<button type="button" id="submit-data">Fetch Data</button>
</form>
And in my index.js
import { Chart } from "frappe-charts/dist/frappe-charts.min.esm";