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

332
Views
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 answers
Answer question

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 Report

0

Maybe you need to install Babel compiler here

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