Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

82
Views
how to import array of object to content script chrome extension

I still learning about how to write chrome extension. I try to import my array of object from myAcc.js to popup.js

but everytime it give me error

Uncaught SyntaxError: Cannot use import statement outside a module
and
Uncaught SyntaxError: Unexpected token 'export'

I have try use module.exports but it didn't work too. is it because chrome extension can't use ES6 import? or I missing something.

popup.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./style/style.css">
    <title>MEGA.nz Account management</title>
</head>
<body>
    <div id='account-box'>
        <div class='button-tab-holder'>
        <button class='switchBtn'>set1</button>
        <button class='switchBtn'>set2</button>
        </div>
        <div class='account-list1 tab-content show'></div>
        <div class='account-list2 tab-content'></div>
    </div>
    <script type="module" src="./js/popup.js"></script>
</body>
</html>

manifest.json

{
    "name": "Account Management",
    "version": "1.0",
    "description": "Account Manangent for multiple account user",
    "manifest_version": 2,
    "browser_action": {
        "default_title": "Account Management",
        "default_popup": "popup.html"
    },
    "permissions": [
        "https://mega.nz/login"
    ],
    "content_scripts": [
        {
        "matches": ["https://mega.nz/login"],
        "css": ["./style/style.css"],
        "js": ["./js/popup.js"]
        }
    ]
}

popup.js

import obj_array from "./js/myAcc";
//do stuff

myAcc.js

const accountObj = [{},{},...]
const accountObjSet2 = [{},{},...]
export default obj_array = [accountObj,accountObjSet2]
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!