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

ReferenceError: item is not defined #624

Open
aL3xa opened this issue May 9, 2014 · 5 comments
Open

ReferenceError: item is not defined #624

aL3xa opened this issue May 9, 2014 · 5 comments

Comments

@aL3xa
Copy link

aL3xa commented May 9, 2014

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?

@randunel
Copy link
Collaborator

randunel commented May 9, 2014

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

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

@aL3xa
Copy link
Author

aL3xa commented May 9, 2014

@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
Copy link
Author

aL3xa commented May 10, 2014

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 ~? 😄

@alexiskattan
Copy link

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

@absynce
Copy link
Contributor

absynce commented Apr 13, 2015

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.

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

4 participants