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

Closed
arvindan opened this issue Mar 18, 2015 · 11 comments
Closed

Cannot find module './types.json' #120

arvindan opened this issue Mar 18, 2015 · 11 comments

Comments

@arvindan
Copy link

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. (/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

@broofa
Copy link
Owner

broofa commented Mar 18, 2015

I'm unable to reproduce this.

kieffer@Roberts-MacBook-Pro$ npm install -g mime
/Users/kieffer/local/node/bin/mime -> /Users/kieffer/local/node/lib/node_modules/mime/cli.js
mime@1.3.4 /Users/kieffer/local/node/lib/node_modules/mime

kieffer@Roberts-MacBook-Pro$ node -e "console.log(require('mime').lookup('txt'))"
text/plain

kieffer@Roberts-MacBook-Pro$

@whitlockjc
Copy link

I just reproduced this exact same error using Express 4.x:

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> (/Users/notyou/projects/myproject/node_modules/express/node_modules/send/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)

I'm working on getting more details but for now, at least @arvindan doesn't have to worry about being alone. ;)

@arvindan
Copy link
Author

Thanks

 On Tuesday, 31 March 2015 7:40 AM, Jeremy Whitlock <notifications@github.com> wrote:

I just reproduced this exact same error using Express 4.x: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. (/Users/notyou/projects/myproject/node_modules/express/node_modules/send/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)
I'm working on getting more details but for now, at least @arvindan doesn't have to worry about being alone. ;)—
Reply to this email directly or view it on GitHub.

@jpv
Copy link

jpv commented Mar 31, 2015

same error for me.
No ./type.js anywhere....
Error: Cannot find module './types.json'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (/home/jpv/dsn-cockpit-pm2/dsn-cockpit/dsn-cockpit-server/node_modules/express/node_modules/send/node_modules/mime/mime.js:87:13)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)

@whitlockjc
Copy link

Node.js v0.10 on the server where this was reproduced for me. Still trying to get more details.

@olalonde
Copy link

olalonde commented Apr 2, 2015

Why is types.json gitignored?

@broofa
Copy link
Owner

broofa commented Apr 3, 2015

@olalonde types.json is built as part of the prepublish step, so technically isn't required as part of the source repo. That said, that entry in .gitignore was removed in a80fa14, which I apparently hadn't pushed. I've remedied that but I don't think that's related to this issue.

@jpv @whitlockjc the common thread here is the send module... which includes the mime-v1.3.4. I've installed express latest and verified that require('express') triggers a call to require('send') and subsequently require('mime') but I still can't repro on my system. 😦 Here's my test log: https://gist.github.com/broofa/b08d4812371193b7a114

@arvindan I tried [unsuccessfully] to repro your bug again. Still no luck. Here's the test log: https://gist.github.com/broofa/ecb06e3daef52ef9c713

Can the three of you try these same steps and let me know what happens? Also note if you're running different versions of npm/node, please.

@qazedx
Copy link

qazedx commented Jun 9, 2015

any news on this? I am struggling with this error for 2 days now, I am using:

node -v
v0.10.25

npm -v
1.4.21

"dependencies": {
    "peerjs": "0.3.10",
    "express": "4.3.1",
    "node-static": "0.7.6",
    "ws": "0.4.25",
    "underscore": "1.4.4",
    "gl-matrix": "2.2.1"
    },

I am on xubuntu 15.04, haven't had any problems when I worked on win 7, switched to linux just recently.

@kevinnsun
Copy link

I had this same problem when trying to run karma after installing various modules (http-errors, utils-merge, etc) I fixed the problem by updating/ reintsalling karma globally using "npm install karma -g"

@HiKat
Copy link

HiKat commented Feb 19, 2016

I fixed this error with $ npm install mime.

@broofa broofa closed this as completed Jun 15, 2017
@bx-h
Copy link

bx-h commented Jun 20, 2019

Try

rm -rf node_modules
npm install -g npm@latest
npm i core-util-is

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

No branches or pull requests

9 participants