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

334
Vistas
Build failed to compile - Attempted import error

My attempt to build for production fails every time because of this error:

Attempted import error: 'decrypt' is not exported from '../../../../util/security' (imported as 'decrypt').

This error only appears when I try to build for production (npm run build).

Here is the way I import my modules:

import {encrypt2, decrypt} from "../../../../util/security";

And how I export it :

module.exports = {

    decrypt: function(encrypted_route) {
        encrypted_route = atob(encrypted_route);
        let [initialVector, salt, aes_route] = encrypted_route.split("::");
        let key = generateKey(salt);

        let cipherParams = CryptoJS.lib.CipherParams.create({
            ciphertext: CryptoJS.enc.Base64.parse(aes_route)
        });

        let unencrypted = CryptoJS.AES.decrypt(
            cipherParams,
            key,
            {iv: CryptoJS.enc.Hex.parse(initialVector)}
        );
        return unencrypted.toString(CryptoJS.enc.Utf8);
    },

};

(The module decrypts my encrypted route)

I checked and the file is in the right place, moreover, in development mode it works as intended.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The solution here is to replace Node.js style exports (module.exports = ) with ES6 exports (export ... or export default ... depending on how you want to import it).

The reason is that import/export styles have to be compatible and while there are scenarios where this could work, mixing the two styles in a React app is not the best idea.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Change your import to:

import * as security from "../../../../util/security";

and use it like:

security.decrypt(...)
about 4 years ago · Juan Pablo Isaza Denunciar
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