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.

Cannot find module 'strtok3/core' from 'node_modules/file-type/core.js'

See original GitHub issue

Hello,

I have version 17.1.2 installed in a project.

When I attempt to use this library I get the error Cannot find module 'strtok3/core' from 'node_modules/file-type/core.js'

This seems to be caused by core.js:3 referencing strtok3/core instead of strtok3/lib/core.

Maybe this is a problem with my local setup, but wanted to see if there was an easy resolution to this issue.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:5
  • Comments:7

github_iconTop GitHub Comments

1reaction
Krankypankycommented, Jul 27, 2022

also facing the same issue after updating from 16.4.0 to 17.1.4

api_1       | ERROR in ./node_modules/file-type/index.js
api_1       | Module not found: Error: Can't resolve 'strtok3' in '/code/node_modules/file-type'
api_1       | 
api_1       | ERROR in ./node_modules/file-type/core.js 681:28
api_1       | Module parse failed: Identifier directly after number (681:28)
api_1       | You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
api_1       | | 				while (children > 0) {
api_1       | | 					const element = await readElement();
api_1       | > 					if (element.id === 0x42_82) {
api_1       | | 						const rawValue = await tokenizer.readToken(new Token.StringType(element.len, 'utf-8'));
api_1       | | 						return rawValue.replace(/\00.*$/g, ''); // Return DocType

UPDATE: I just wanted to update this dependency because of the security issue wit the malformed mkv file. I just found out that npm audit can also fix this issue by bumping the sub-dependency: npm update file-type --depth 1

Issue solved for me.

0reactions
Borewitcommented, Aug 3, 2022

The path ‘strtok3/core’ was wrong indeed, sorry issue was hard to distinct from the many basic ESM issues. Issue fixed by:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to get file-type to run in browser (modules strtok3/core ...
file-type version 17.1.1, webpack version 4.44.2. we have used solution from 502 to solve node:buffer error to run the library in browser.
Read more >
strtok3 - npm
A promise based streaming tokenizer for Node.js and browsers. This node module is a successor of strtok2. The strtok3 contains a few methods...
Read more >
Importing pure ESM module in TS project fails Jest test with ...
I have made a sandbox here. Summary of my code: import { fileTypeFromBuffer } from "file-type";. Jest config ...
Read more >
[SOLVED] Unable to resolve some modules: "node:fs" - help
Edit: Got the error when import file-type package import { fileTypeFromFile } ... "strtok3/core" in /banana/node_modules/file-type/core.js ...
Read more >
cannot find module or its corresponding type declarations file
Every error is the same: Cannot find module 'node:stream' or its corresponding type declarations. and it occurs in 5 places: node_modules/file-type/core.d.ts:1: ...
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