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 './types.json'

See original GitHub issue

I installed the module (fs, util, mime) in shared folder written the below script

var fs = require("fs"),
    util = require("util");

var mime = require("mime");

var dataUri = base64Image("/home/arvindan/testing/abc.jpg");
console.log(dataUri);

function base64Image(src) {
    var data = fs.readFileSync(src).toString("base64");
    return util.format("data:%s;base64,%s", mime.lookup(src), data);
}

on execution throwing below error Error: Cannot find module ‘./types.json’ at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/home/arvindan/node_modules/mime/mime.js:87:13) at Module._compile (module.js:456:26) at Object.Module._extensions…js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17)

please help me to resolve the issue

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
HiKatcommented, Feb 19, 2016

I fixed this error with $ npm install mime.

0reactions
bx-hcommented, Jun 20, 2019

Try

rm -rf node_modules
npm install -g npm@latest
npm i core-util-is
Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: "Cannot find module 'x.json'" TypeScript Error
When trying to import a JSON file in your TypeScript project, you may see the following error: Cannot find module 'my-json-file.json'.
Read more >
require a json file results in an error: Cannot find module
I tried to: add "resolveJsonModule": true to the compilerOptions in jsconfig.json , but it does not work.
Read more >
Cannot find module 'X' Error in TypeScript | bobbyhadz
The "Cannot find module or its corresponding type declarations" error occurs when TypeScript cannot locate a third-party or local module in our project....
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
you're trying to import an item from a module you don't have installed in your project directory; you're importing some things from an...
Read more >
Fixing The "Cannot Find Module" Error In TypeScript
Fixing The "Cannot Find Module" Error In TypeScript · The package is not installed. · Something is wrong with the node_modules folder. ·...
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