question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not import the library

See original GitHub issue

Bug description I can not import the package from node. I spent 10h.

Expected behavior The package is imported and I can use the parseFile function.

Audio file demonstrating the problem ~/music-metadata
❯ npm i music-metadata

added 17 packages, and audited 18 packages in 1s

8 packages are looking for funding run npm fund for details

found 0 vulnerabilities

~/music-metadata-test  
❯ node
Welcome to Node.js v18.4.0.
Type ".help" for more information.
> require('music-metadata')
Uncaught:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/janwirth/music-metadata/node_modules/music-metadata/lib/index.js not supported.
Instead change the require of index.js in null to a dynamic import() which is available in all CommonJS modules.
    at __node_internal_captureLargerStackTrace (node:internal/errors:477:5)
    at new NodeError (node:internal/errors:388:5)
    at Module._extensions..js (node:internal/modules/cjs/loader:1139:19)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:834:12)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18) {
  code: 'ERR_REQUIRE_ESM'
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
janwirthcommented, Oct 23, 2022

Downgrading to version 7 solved it for me.

0reactions
Borewitcommented, Oct 28, 2022

The lack of backward compatibility in ESM modules is a true nightmare @janwirth.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot import Python Libraries anywhere - Super User
I am on MacOS 10.14.5. I currently cannot import any Python third-party Library from anywhere (including VSCode, Pycharm and terminal). Detail.
Read more >
Can't import my own modules in Python - Stack Overflow
In your particular case it looks like you're trying to import SomeObject from the myapp.py and TestCase.py scripts. From myapp.py, do import SomeObject....
Read more >
How to Fix ImportError: Cannot Import Name in Python - Rollbar
The Python ImportError: cannot import name error occurs when an imported class is not accessible or is in a circular dependency.
Read more >
5. The import system — Python 3.11.1 documentation
When a module is first imported, Python searches for the module and if found, it creates a module object 1, initializing it. If...
Read more >
Resolve "Unable to import module" errors from Python ... - AWS
Important: Make sure that you put the library that you import for Python inside the /python folder. Resolution. Note: The following steps show ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found