Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

196
Vistas
How to import sodium-plus directly into a .js file? "module does not provide an export named 'default'"

I would like to import sodium-plus to use within a .js file in a Chrome extension. The library's documentation only shows how to include the extension from an html file with a <script> tag. When I do that I get an error:

Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'".

I tried to import directly through a .js file:

import SodiumPlus from "./sodium-plus.min.js";
(async function() {
    if (!window.sodium) window.sodium = await SodiumPlus.auto();

    // You can now use the sodium object here.

    // Just some example code to ensure it's running:
    let random = await sodium.randombytes_buf(32);
    let hash = await sodium.crypto_generichash('hello world');
    console.log({
        'random': random.toString('hex'),
        'hash': hash.toString('hex')
    });
})();

But received an error:

Uncaught SyntaxError: The requested module './sodium-plus.min.js' does not provide an export named 'default'

Is there any way to fix that? Alternatively, is there a similar library that would be easier to import into a .js file of a Chrome extension?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda