Borewit / music-metadata

Stream and file based music metadata parser for node. Supporting a wide range of audio and tag formats.
MIT License
898 stars 90 forks source link

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

Closed arnab closed 1 year ago

arnab commented 1 year ago

Has the question been asked before?

Question

I am trying to use this library from a Typescript function (running under Node.js 18 environment) deployed as a Firebase function.

Here is what I have (package.json has "music-metadata": "^8.1.4"):

import axios from "axios";
import * as mm from "music-metadata";

const response = await axios.get(urlString, {responseType: "arraybuffer"});
const buffer = Buffer.from(response.data);
const metadata = await mm.parseBuffer(buffer, contentType);
Logger.info(`Parsed audio metadata: ${JSON.stringify(metadata)}`);

TS is failing to compile with:

node_modules/music-metadata/lib/apev2/APEv2Token.d.ts:2:27 - error TS2307: Cannot find module 'strtok3/core' or its corresponding type declarations.

2 import { IGetToken } from 'strtok3/core';
                            ~~~~~~~~~~~~~~

node_modules/music-metadata/lib/core.d.ts:3:26 - error TS2307: Cannot find module 'strtok3/core' or its corresponding type declarations.

3 import * as strtok3 from 'strtok3/core';
                           ~~~~~~~~~~~~~~

node_modules/music-metadata/lib/core.d.ts:5:27 - error TS2307: Cannot find module 'strtok3/core' or its corresponding type declarations.

5 export { IFileInfo } from 'strtok3/core';
                            ~~~~~~~~~~~~~~

[9:18:09 AM] Found 3 errors. Watching for file changes.

What am I missing?

arnab commented 1 year ago

This error goes away if I use the last major version of this library:

"music-metadata": "^7.13.4"

Is there something I need to do to use the latest 8.x version in a TS/Node.js 18 environment?

Borewit commented 1 year ago

Duplicate of #1373