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

275
Views
Cytoscape.js in an ESM environment with npm: Import problem

How can I import cytoscape.js into my npm ESM project?

Versions I use are: npm: '8.1.4', node: '14.15.3'.

My package.json defines that I want to do ESM: "type": "module",

The cytoscape.js documentation states the following:

To install Cytoscape.js via npm: npm install cytoscape

To use Cytoscape.js in an ESM environment with npm (e.g. Webpack or Node.js with the esm package): import cytoscape from 'cytoscape';

I followed the instructions. However, the import results in the error:

Uncaught SyntaxError: The requested module './../../node_modules/cytoscape/dist/cytoscape.cjs.js' does not provide an export named 'default'

Well, that is correct since the commonjs version was loaded. But in an ESM environment cytoscape.esm.js should be loaded instead of cytoscape.cjs.js. However, node_modules/cytoscape/package.json says to use the commonjs version: "main": "dist/cytoscape.cjs.js",

So I tried to import the ESM version directly in my code:

import cytoscape from './../../node_modules/cytoscape/dist/cytoscape.esm.js';

Cytoscape.js is now imported. However, I get the followup error in an dependent package:

Uncaught SyntaxError: The requested module './../../heap/index.js' does not provide an export named 'default' in line cytoscape.esm.js:24

I'm kind of stuck now. Other related questions did not help so far. I'll be happy for any suggestion or even solution. Thanks in advance!

about 4 years ago · Juan Pablo Isaza
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!