0

I've searched this error on different platform and tried the answers but none worked here is my code

javascript:

import { Octokit } from "./octokit.js";
const TOKEN = "mytoken";
const octokit = new Octokit({
    auth: TOKEN
});

html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>gitmail</title>
</head>
<body>
    
</body>
<script type='module' src="test.js" ></script>
</html>

I tried with and without ".js" . tried with "../" and "./" I even wrote the full path to the module but that didn't help as well.

I am using VS code as editor and the live server. Not only this module but other modules do not work as well

EmPlusPlus
  • 171
  • 1
  • 4
  • 19

1 Answers1

0

It could be due to several reasons but without more information it's hard to tell.

  1. Looking at your code I'm can only assume that you does not use Node.js, which mean that the octokit.js is a local file within your project folder. If so, have you double checked the import path? test.js must be on the same folder as octokit.js.
  2. Check for bad spelling, is test.js correct?
  3. CORS error. For that I'd refer to this post: Javascript module not working in browser?
maladroy
  • 11
  • 1