Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

43
Vistas
Javascript lazy loading cannot find path but static loading works

When I do import { foo } from 'NpmPackage'; it works

But when I try the below I get the error that Cannot find module 'NpmPackage'

async function tryImport(path) {
  try {
    return await import(path);
  } catch (error) {
    console.warn('doesnt work', error);
    return {};
  }
}

const { foo } = tryImport('NpmPackage');
7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos