Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'strtok3/core' or its corresponding type declarations. #1373

Closed
d-sphinx opened this issue Oct 25, 2022 · 5 comments
Closed

Comments

@d-sphinx
Copy link

"music-metadata": "^8.1.0"

[{
"resource": "/c:/_WORK/link_metadata/node_modules/music-metadata/lib/apev2/APEv2Token.d.ts",
"owner": "typescript",
"code": "2307",
"severity": 8,
"message": "Cannot find module 'strtok3/core' or its corresponding type declarations.",
"source": "ts",
"startLineNumber": 2,
"startColumn": 27,
"endLineNumber": 2,
"endColumn": 41
}]

APEv2Token.d.ts tries to import { IGetToken } from 'strtok3/core';

There is no 'core' file or dir in node_modules/strtok3

@Borewit
Copy link
Owner

Borewit commented Oct 25, 2022

Yes there is:

https://github.com/Borewit/strtok3/blob/91791f8f2ef80f905bdc0bc1088fd96ff2076ae9/package.json#L42

Problem is that your environment lacks proper ESM support, duplicate of #1217

@Borewit Borewit closed this as completed Oct 25, 2022
@d-sphinx
Copy link
Author

Yes there is:

https://github.com/Borewit/strtok3/blob/91791f8f2ef80f905bdc0bc1088fd96ff2076ae9/package.json#L42

Problem is that your environment lacks proper ESM support, duplicate of #1217

How do I fix it? My node is v14.20.1 (latest in 14 branch) - is this causes a problem?

@Borewit
Copy link
Owner

Borewit commented Oct 25, 2022

Node version should be ^14.13.1 || >=16.0.0", so that is fine.

Tests are passing against the latest Node v14:

https://github.com/Borewit/music-metadata/blob/master/.github/workflows/nodejs-ci.yml#L50

Maybe upgrade your TypeScript dev dependencies, seems on that level as it complaining about typings.

@bradleat
Copy link

bradleat commented Nov 10, 2022

I think the issue for most build tools (including the typescript compiler in the default configuration), is that the import should be to strtok3/lib/core

adding this to the compilerOptions of the tsconfig works:

"paths": {
        "strtok3/core": ["./node_modules/strtok3/lib/core"]
      }

or use moduleResolution: "node16" in the same place

The problem with the latter method is that is incompatible with many web packers (like Parcel or WebPack). In this case, you should use https://github.com/Borewit/music-metadata-browser instead.

@Borewit
Copy link
Owner

Borewit commented Nov 11, 2022

Thanks for sharing your experience @bradleat, on the long run I want to merge music-metadata-browser with (to) music-metadata, as ESM allows different import path for node.js and browser.

Please also raise this shortcomings at the web bundlers not supporting this. ESM is the official standard format after-all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants