mozilla / doctorjs

A set of static analysis tools for JavaScript
Other
739 stars 67 forks source link

fix for require module error #40

Closed zmmbreeze closed 12 years ago

zmmbreeze commented 12 years ago

nodejs version: v0.65 error log:

node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: Cannot find module 'underscore' at Function._resolveFilename (module.js:334:11) at Function._load (module.js:279:25) at Module.require (module.js:357:17) at require (module.js:368:17) at Object. (/usr/local/bin/jsctags:42:9) at Module._compile (module.js:432:26) at Object..js (module.js:450:10) at Module.load (module.js:351:31) at Function._load (module.js:310:12) at Array.0 (module.js:470:10)

hendrixski commented 12 years ago

$ echo $NODE_PATH /home/me/doctorjs/lib/jsctags:/usr/bin/node

$ node -v v0.7.9-pre

I ran this against a folder that had only jquery1.7.2. And I updated to the doctorjs commit from 2012-04-14 12:45:37 (with the comment "Bugfix for exports in commonJS mode."). I got the error below so ran make uninstall then I checked out the branch that this pull request is for, ran make install, then tried again but I still got the same error :(

I saw an earlier bug with a similar problem, that jsctags was not in the NODE_PATH. Here it is, I think just newer versions of node don't check that or something.

My error: $ jsctags javascript/ Didn't find a name for constructor

node.js:256 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: Didn't find a name for constructor at errorWithCode (/home/me/doctorjs/lib/cfa2/jscfa.js:157:11) at Array.toType (/home/me/doctorjs/lib/cfa2/jscfa.js:1574:11) at /home/me/doctorjs/lib/cfa2/jscfa.js:1994:18 at /home/me/doctorjs/lib/cfa2/jscfa.js:2022:39 at Array.forEach (native) at Aval.forEachObj (/home/me/doctorjs/lib/cfa2/jscfa.js:2022:14) at Aval.toType (/home/me/doctorjs/lib/cfa2/jscfa.js:1993:8) at funToType (/home/me/doctorjs/lib/cfa2/jscfa.js:3721:34) at Array.toType (/home/me/doctorjs/lib/cfa2/jscfa.js:1568:28) at /home/me/doctorjs/lib/cfa2/jscfa.js:1994:18

HTH

mingliangguo commented 12 years ago

I had the same issue when I try to build tags for my dojo code. It runs well for most of the files, but will fail always with one file whose name is NodeList.js. I didn't found something special with it. If you need the file for further investigation, I can provide it to you. It's from on older version of dojo, 1.6. In 1.7.2, it works well for the same file. I guess this clue might help you to solve it as well.

WayneYe commented 12 years ago

I got exactly the same issue, and I never successfully run jsctags....

Mac Lion

node -v v0.6.17

npm -v 1.1.21

NODE_PATH

/usr/local/lib/jsctags/:/usr/local/lib/npm_modules:/usr/local/lib/node

zmmbreeze commented 12 years ago

@johncch Thanks for you to remind me, I made a new pull request.

MiguelSanchezGonzalez commented 12 years ago

@zmmbreeze You forgot one dot! is:

../underscore

zmmbreeze commented 12 years ago

@MiguelSanchezGonzalez Thanks! Really stupid mistake, fixed.

ando-takahiro commented 12 years ago

+1

jamiemill commented 12 years ago

+1, this fixed the error for me. Was getting OP's error every time I tried to run jsctags.