compound icon indicating copy to clipboard operation
compound copied to clipboard

ReferenceError: item is not defined

Open aL3xa opened this issue 11 years ago • 5 comments

I'm getting this error in the project I'm working on:

project|master⚡ ⇒ node .
Failed to load c++ bson extension, using pure JS version
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0

/home/user/projects/client/project/node_modules/compound/lib/server/structure.js:121
                    for (var i in item.prototype) {
                                  ^
ReferenceError: item is not defined
    at readNode (/home/user/projects/client/project/node_modules/compound/lib/server/structure.js:121:35)
    at Array.forEach (native)
    at read (/home/user/projects/client/project/node_modules/compound/lib/server/structure.js:92:33)
    at /home/user/projects/client/project/node_modules/compound/lib/server/structure.js:73:21
    at Array.forEach (native)
    at CompoundServer.loadStructure (/home/user/projects/client/project/node_modules/compound/lib/server/structure.js:71:36)
    at CompoundServer.initCompound (/home/user/projects/client/project/node_modules/compound/lib/compound.js:145:18)
    at CompoundServer.initCompoundServer [as init] (/home/user/projects/client/project/node_modules/compound/lib/server/compound.js:54:29)
    at /home/user/projects/client/project/node_modules/compound/lib/compound.js:84:22
    at process._tickCallback (node.js:419:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)
    at node.js:906:3

Everything works like a charm after I issue npm install, app works for a while, and then for unknown reason it breaks with all this stuff in stdout. I'm using [email protected] with node v0.10.28,

Any ideas?

aL3xa avatar May 09 '14 14:05 aL3xa

@1602 that is leftover code, item used to be defined like this:

                var item = doRequire ?
                    requireFile(file, doRequire) :
                    fs.readFileSync(file).toString();

randunel avatar May 09 '14 14:05 randunel

@randunel thanks for prompt reply. OK, this code will apparently not work. Where is doRequire defined? AFAICS, requireFile function is not available in the scope where bug occurs, and if doRequire evals to false, fs.readFileSync(file).toString() will evaluate to load(\'application\');\n. What do you recommend me to do?

aL3xa avatar May 09 '14 16:05 aL3xa

OK, I finally got it. It was due to *~ backup files created by Emacs in the app/controllers/ directory. What is the prefered way of gracefully ignoring these ones? Apart from issuing a pull request with simple regex match that will exclude files ending with ~? :smile:

aL3xa avatar May 10 '14 17:05 aL3xa

yes i also had a extra file (.js instead of .coffee) in the controller. When I removed the .js file it was working again.

alexiskattan avatar Apr 04 '15 02:04 alexiskattan

I had to invert it to the following:

if (key !== 'controllers' || !(name in contents)) {
  compound.structure.register(key, {
    name: name,
    file: path.normalize(file),
    stat: stat
  });
}

Disclaimer: I don't know if this will affect certain situations...but I can't tell how it worked with the item.prototype since the var item = doRequire ?... stuff was removed.

absynce avatar Apr 13 '15 18:04 absynce