Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Cannot read property 'type' of undefined #33

Open
boushley opened this issue Jan 15, 2012 · 6 comments
Open

Cannot read property 'type' of undefined #33

boushley opened this issue Jan 15, 2012 · 6 comments

Comments

@boushley
Copy link

I have had a problem running jsctags on underscore.js and backbone.js both of them reporting Cannot read property 'type' of undefined. The entire error looks like the following:

Cannot read property 'type' of undefined

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
TypeError: Cannot read property 'type' of undefined
    at Object.<anonymous> (/usr/local/lib/cfa2/jscfa.js:1168:12)
    at Object.recur (/usr/local/lib/cfa2/jscfa.js:578:41)
    at /usr/local/lib/cfa2/jscfa.js:588:13
    at Array.forEach (native)
    at Object._haskids (/usr/local/lib/cfa2/jscfa.js:586:8)
    at Object.recur (/usr/local/lib/cfa2/jscfa.js:578:41)
    at /usr/local/lib/cfa2/jscfa.js:588:13
    at Array.forEach (native)
    at Object._haskids (/usr/local/lib/cfa2/jscfa.js:586:8)
    at Object.recur (/usr/local/lib/cfa2/jscfa.js:578:41)

The error message didn't seem to point me towards the source of the error. However in both of these libraries I was able to track down the source of the error to the following.

In backbone.js:

  if (typeof exports !== 'undefined') {

and

  if (!_ && (typeof require !== 'undefined')) _ = require('underscore');

In underscore.js:

 if (typeof exports !== 'undefined') {
    if (typeof module !== 'undefined' && module.exports) {

It appears this method of checking if we are in node.js is causing problems.

Any suggested workaround for this?

@yhslai
Copy link

yhslai commented Jan 17, 2012

I have exactly the same issue! My node -v is v0.6.2

@tedeyang
Copy link

yes,me too!

@aslushnikov
Copy link

same thing for me; running node -v is v0.6.5

@ghost
Copy link

ghost commented Apr 13, 2012

+1, running v.0.6.15

@clausreinke
Copy link

Could this be related to the second item in #23? It has been a long time, but looks the same.

In this case, an expected extra argument isn't passed, so p = arguments[3] isn't defined and p.type falls over (line 1168, as indicated in the stack trace). #23 works around by adding a guard p && p.type===STRING. This is just a workaround, not a fix, but might help.

@dimvar
Copy link

dimvar commented Apr 14, 2012

@boushley can you tell me which drjs commit you're using, and what options are you passing to jsctags.js?

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

No branches or pull requests

6 participants