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

jsctags does not work with nodejs 0.10.0 #52

Closed
sangwook-kim opened this issue Mar 20, 2013 · 12 comments
Closed

jsctags does not work with nodejs 0.10.0 #52

sangwook-kim opened this issue Mar 20, 2013 · 12 comments

Comments

@sangwook-kim
Copy link

Hi.
I'm on Ubuntu. and I found a problem yesterday.
Ubuntu package manager provides nodejs 0.6.x.
I'm trying grunt 0.4.* and grunt 0.4.x needs nodejs >= 0.8.
So I've downloaded and built nodejs 0.10.x (which is official new stable version.)

Then, jsctags has broke and issued some error message complaining about

Array.prototype.push called on null or undefined

/usr/local/bin/jsctags:195
throw e;
^
TypeError: Array.prototype.push called on null or undefined
at Object.exports.Tags.Object.create.Trait.compose.Trait.add (/usr/local/lib/jsctags/ctags/index.js:71:30)
at Object.exports.Tags.Object.create.Trait.compose.Trait.scan (/usr/local/lib/jsctags/ctags/index.js:105:14)
at processPath (/usr/local/bin/jsctags:189:18)
at Object. (/usr/local/bin/jsctags:207:5)
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 Function.Module.runMain (module.js:497:10)

at startup (node.js:119:16)

I figured a workaround for this situation.

  1. sudo -H npm install -g n : Install 'n' to use as node version management tool.
  2. sudo n 0.10.0 : to recognize 0.10.x that i've already installed
  3. sudo n 0.8.22 : to install 0.8.x, which works fine for jsctags and grunt.

maybe you need to sudo n use 0.8.22 to make 0.8.22 default. I'm not quite familiar with 'n'.

and when you get "node -v" "0.8.22". All problem solved for me.

Still, I think it would be better for jsctags work with node 0.10.x.

Thank you.

@sangwook-kim
Copy link
Author

sorry, that I'm not familiar with markdown yet...

@tiantian20007
Copy link

After downgrade to 0.8.22, tag show up. However, the scope of object and function is lost.
This issue continue:
#5

@chilkari
Copy link

Not sure if this will help you, but I was having the same issue. Without knowing much about the doctorjs code, it appears to be assuming this.tags is an array: [] when it hasn't been initialized.

I modified /usr/local/lib/jsctags/ctags/index.js as follows:

Modified the constructor for Tags to simply init:
exports.Tags = function(initialTags) {
this.init();
}

Added a tags list to the prototype setup, around lines 53-55 (may be slightly less for you due to comments):

exports.Tags.prototype = Object.create(Object.prototype, Trait.compose(Trait({

tags: [],    // <--  added this

_search: function (id, pred) {

And it appears to work for me with node:0.10.0

@Nek
Copy link

Nek commented Apr 8, 2013

Thanks a lot! That worked for me too.

@sangwook-kim
Copy link
Author

Thanks, chilkari!

Works fine for me. Maybe there could be some performance issue, or not.
But I'm satisfied with your patch.

@demizer
Copy link

demizer commented Apr 18, 2013

I don't think this issue should have been closed. The solution worked for me as well.

@dmitrym0
Copy link

This worked for me as well.

velichkov pushed a commit to velichkov/doctorjs that referenced this issue May 23, 2014
Applied patch as described in
mozilla#52.
velichkov pushed a commit to velichkov/doctorjs that referenced this issue May 23, 2014
Applied patch as described in
mozilla#52.
@pacuna
Copy link

pacuna commented May 24, 2014

thanks!

@nishantvarma
Copy link

Good patch though @chilkari -Thanks

@bbrink68
Copy link

Confirmed, this works. I agree this probably shouldn't have been closed quite yet.

For anyone interested, the precise changes made to the file:
sudo vim /usr/local/lib/jsctags/ctags/index.js

On line 51

exports.Tags.prototype = Object.create(Object.prototype, Trait.compose(Trait({
    tags: [], // Added This
    _search: function (id, pred) {
        var shadowTag = { name: id };
        var tags = this.tags;
        var index = _(tags).sortedIndex(shadowTag, function (tag) {
            return tag.name;
        });
        ...
        ...

Here is a sed insert if you'd rather not bother editing yourself:

sudo sed -i '51i tags: [],' /usr/local/lib/jsctags/ctags/index.js

@mmolhoek
Copy link

mmolhoek commented Aug 7, 2014

work for me aswell :) now searching for a good vim plugin...

@haibzhong
Copy link

it works. thanks.

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