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

338
Vistas
cannot import npm installed modules (lightweight-charts)

I'm new to the world of JS and recently trying to write a toy app using lightweight-charts. I've gone through several tutorials and learned some basic concepts. But I'm so mad at myself that I still cannot figure out in what context can I use the 'es6 via npm' example mentioned in the lightweight-chart NPM page above. The CDN example seems to be fine, though.

Here is what I did

  1. install lightweight-charts locally. - npm install lightweight-charts

  2. create a test.mjs in the same directory, which contains only one lines.

import { createChart } from 'lightweight-charts';
  1. run the code. node test.mjs

But I got the following errors

SyntaxError: Named export 'createChart' not found. The requested module 'lightweight-charts' is a CommonJS module, which may not support all module.exports as named exports.

It does not make sense for me because the official npm site says es6 supported, but the error messages seem to indicate that this module is for CommonJS. Even after I
rewrote this in CommonJS style using 'require' syntax and rename "test.mjs" to "test.js", some dependency modules are still using 'import' syntax and caused some so
rt of "cannot use import statement outside a module" errors.

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

This package is not meant to be executed on the backend with NodeJS. It will only work in the browser.

about 4 years ago · Santiago Trujillo Denunciar

0

Maybe you need to install Babel compiler here

about 4 years ago · Santiago Trujillo 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