tower / tower

UNMAINTAINED - Small components for building apps, manipulating data, and automating a distributed infrastructure.
http://tower.github.io
MIT License
1.79k stars 121 forks source link

Constant 'App.' Wasn't Found Error in Vanilla Install #342

Closed spencerbeggs closed 11 years ago

spencerbeggs commented 11 years ago

I am doing a vanilla install of tower with node v0.8.12 and npm 1.1.63.

tower new app
cd app
npm install
cake watch

In a new terminal window I run my generators and start the server.

tower generate scaffold User name:string email:string
node server

On startup I get:

/app/node_modules/tower/lib/tower-support/shared/shared.js:242
        throw new Error("Constant '" + string + "' wasn't found");
              ^
Error: Constant 'App.' wasn't found
    at _.extend.constant (/app/node_modules/tower/lib/tower-support/shared/shared.js:242:15)
    at _.extend.constant (/app/node_modules/tower/lib/tower-support/shared/shared.js:240:22)
    at Function.Tower.ControllerScopes.ClassMethods.scope (/app/node_modules/tower/lib/tower-controller/shared/scopes.js:13:25)
    at /app/app/controllers/server/usersController.coffee:17:21
    at Object.<anonymous> (/app/app/controllers/server/usersController.coffee:21:5)
    at Object.<anonymous> (/app/app/controllers/server/usersController.coffee:23:4)
    at Module._compile (module.js:449:26)
    at Object.require.extensions..coffee (/app/node_modules/coffeecup/node_modules/coffee-script/lib/coffee-script/coffee-script.js:22:21)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

I had this working in an earlier version, but there seems to be a problem now. Any help would be appreciated.

jridgway commented 11 years ago

I just ran into this as well.

WesKetch commented 11 years ago

Same here, I followed the instructions at towerjs.org to get an app up and running and got the same error.

br8kpoint commented 11 years ago

strike three!

I have been looking for a solution for this today as well. I was able to get cake watch to work without error if you do vanilla install without running the generator which makes me think something is wrong in the generator.

termsurfhare commented 11 years ago

I think the directions may be off. The watcher doesn't currently notice when files are created I don't think (this is an issue with grunt, but grunt 0.4.0 which is going to be released soon fixes this).

If you run the scaffold generator, and then run cake watch, does it work then?

jridgway commented 11 years ago

I get the following after running cake watch:

$ cake watch
Default database not set, using Memory store
Loading "grunt.coffee" tasks and helpers...ERROR
>> Error: Constant 'App.' wasn't found
<WARN> Task "start" not found. Use --force to continue. </WARN>

Aborted due to warnings.
br8kpoint commented 11 years ago

killing cake watch and executing again produces the same error. Also running node server will produce

   info  - socket.io started
Tower development server listening on port 3000

/home/mike/Work/callcenter_tower/node_modules/tower/lib/tower-support/shared/shared.js:242
        throw new Error("Constant '" + string + "' wasn't found");
              ^
Error: Constant 'App.' wasn't found
    at _.extend.constant (/home/mike/Work/callcenter_tower/node_modules/tower/lib/tower-support/shared/shared.js:242:15)
    at _.extend.constant (/home/mike/Work/callcenter_tower/node_modules/tower/lib/tower-support/shared/shared.js:240:22)
    at Function.Tower.ControllerScopes.ClassMethods.scope (/home/mike/Work/callcenter_tower/node_modules/tower/lib/tower-controller/shared/scopes.js:13:25)
    at /home/mike/Work/callcenter_tower/app/controllers/server/usersController.coffee:27:21
    at Object.<anonymous> (/home/mike/Work/callcenter_tower/app/controllers/server/usersController.coffee:31:5)
    at Object.<anonymous> (/home/mike/Work/callcenter_tower/app/controllers/server/usersController.coffee:33:4)
    at Module._compile (module.js:449:26)
    at Object.require.extensions..coffee (/home/mike/Work/callcenter_tower/node_modules/coffeecup/node_modules/coffee-script/lib/coffee-script/coffee-script.js:22:21)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
spencerbeggs commented 11 years ago

Still looking into this. I installed grunt 0.4.0a:

npm install -g grunt@0.4.0a

and then ran through the vanilla install again:

tower new app
cd app
npm install

Looks like grunt 0.4.0a requires Gruntfile.js instead of grunt.js so:

mv grunt.coffee Gruntfile.coffee

But when I run cake watch I get:

Loading "Gruntfile.coffee" tasks...
ERROR
>> TypeError: Object #<Object> has no method 'registerHelper'
Warning: Task "start" not found. Use --force to continue.

Aborted due to warnings.

If I run node server I don't get an error, but of course things aren't built the right way.

thehydroimpulse commented 11 years ago

I'm pretty sure tower has not yet migrated to 0.4.0a. It seems like there are more differences in the newest version and previous versions that just the filename. That would explain why your getting more errors. Just go npm install and npm install grunt -g and you should be on a compatible version. I tried it out this morning and everything works out. On Oct 25, 2012 10:49 AM, "C. Spencer Beggs" notifications@github.com wrote:

Still looking into this. I installed grunt 0.4.0a:

npm install -g grunt@0.4.0a

and then ran through the vanilla install again:

tower new app cd app npm install

Looks like grunt 0.4.0a requires Gruntfile.js instead of grunt.js so:

mv grunt.coffee Gruntfile.coffee

But when I run cake watch I get:

Loading "Gruntfile.coffee" tasks... ERROR

TypeError: Object # has no method 'registerHelper' Warning: Task "start" not found. Use --force to continue.

Aborted due to warnings.

If I run node server I don't get an error, but of course things aren't built the right way.

— Reply to this email directly or view it on GitHubhttps://github.com/viatropos/tower/issues/342#issuecomment-9785026.

spencerbeggs commented 11 years ago

You were able to do a vanilla install with a generator per the example? I can get it to boot up after install, but once I use a generator I get Error: Constant 'App.' wasn't found

jridgway commented 11 years ago

Same here. I'm digging into Tower to figure out what is going on but no luck so far.

jridgway commented 11 years ago

@viatropos, I'm totally stuck here. I'm very excited to use your framework, but I can't even take it for a spin. Can you help out? Any tips would be greatly appreciated. Running cake watch/build before and after generating code doesn't help.

termsurfhare commented 11 years ago

On the road, will get more into this with u in a bit. Check these things though:

  • node version
  • coffeescript version (global and local)
  • tower version
  • grunt version (global, maybe local but I don't think were using local grunt)
  • OS version

This seems like a coffeescript compilation problem. Try to npm install it in your app. Also, are you using a linked tower (via npm link tower where your linking a locally cloned version of the tower repo from github) or did you npm install it?

Also make sure both the local and global versions of tower are the same, and grunt should be 0.3.x, not 0.4.x (they may have updated in which case I will need to update tower.

Let me know if any luck!

jridgway commented 11 years ago

My node is version 0.8.12. I noticed that 0.8.13 is the latest but not the current Mac OS package version or the brew version. Should I install 0.8.13 from source? Also, I installed coffee-script and grunt locally, but no luck. Tower version is 0.4.12. Thanks for the tips! i'll keep trying.

jridgway commented 11 years ago

Oh, I'm on Mac OS 10.6.8.

jridgway commented 11 years ago

If it helps, here are my global modules:

$ npm list -g
/usr/local/lib
├── coffee-script@1.4.0
├─┬ grunt@0.3.17
│ ├── async@0.1.22
│ ├── colors@0.6.0-1
│ ├─┬ connect@2.4.6
│ │ ├── bytes@0.1.0
│ │ ├── cookie@0.0.4
│ │ ├── crc@0.2.0
│ │ ├── debug@0.7.0
│ │ ├── formidable@1.0.11
│ │ ├── fresh@0.1.0
│ │ ├── pause@0.0.1
│ │ ├── qs@0.5.1
│ │ └─┬ send@0.0.4
│ │   ├── mime@1.2.6
│ │   └── range-parser@0.0.4
│ ├── dateformat@1.0.2-1.2.3
│ ├─┬ glob-whatev@0.1.8
│ │ └─┬ minimatch@0.2.9
│ │   ├── lru-cache@2.0.4
│ │   └── sigmund@1.0.0
│ ├─┬ gzip-js@0.3.1
│ │ ├── crc32@0.2.2
│ │ └── deflate-js@0.2.2
│ ├── hooker@0.2.3
│ ├─┬ jshint@0.9.1
│ │ ├─┬ cli@0.4.3
│ │ │ └─┬ glob@3.1.14
│ │ │   ├── graceful-fs@1.1.14
│ │ │   ├── inherits@1.0.0
│ │ │   └─┬ minimatch@0.2.9
│ │ │     ├── lru-cache@2.0.4
│ │ │     └── sigmund@1.0.0
│ │ └─┬ minimatch@0.0.5
│ │   └── lru-cache@1.0.6
│ ├─┬ nodeunit@0.7.4
│ │ └─┬ tap@0.3.1
│ │   ├── buffer-equal@0.0.0
│ │   ├── deep-equal@0.0.0
│ │   ├─┬ difflet@0.2.3
│ │   │ ├── charm@0.0.8
│ │   │ └── traverse@0.6.3
│ │   ├── inherits@1.0.0
│ │   ├── mkdirp@0.3.4
│ │   ├─┬ nopt@2.0.0
│ │   │ └── abbrev@1.0.3
│ │   ├─┬ runforcover@0.0.2
│ │   │ └─┬ bunker@0.1.2
│ │   │   └─┬ burrito@0.2.12
│ │   │     ├── traverse@0.5.2
│ │   │     └── uglify-js@1.1.1
│ │   ├── slide@1.1.3
│ │   └── yamlish@0.0.5
│ ├─┬ nopt@1.0.10
│ │ └── abbrev@1.0.3
│ ├─┬ prompt@0.1.12
│ │ ├── pkginfo@0.2.3
│ │ └─┬ winston@0.5.11
│ │   ├── eyes@0.1.8
│ │   ├─┬ loggly@0.3.11
│ │   │ ├── request@2.9.203
│ │   │ └── timespan@2.2.0
│ │   └── stack-trace@0.0.6
│ ├── semver@1.0.14
│ ├─┬ temporary@0.0.4
│ │ └── package@1.0.1
│ ├── uglify-js@1.3.4
│ ├── underscore@1.2.4
│ └── underscore.string@2.1.1
├─┬ npm@1.1.63
│ ├── abbrev@1.0.3
│ ├── ansi@0.1.2
│ ├── archy@0.0.2
│ ├── block-stream@0.0.6
│ ├── chownr@0.0.1
│ ├── fstream@0.1.19
│ ├─┬ fstream-npm@0.1.2
│ │ └── fstream-ignore@0.0.5
│ ├── glob@3.1.13
│ ├── graceful-fs@1.1.14
│ ├── inherits@1.0.0
│ ├── ini@1.0.5
│ ├─┬ init-package-json@0.0.6
│ │ └── promzard@0.2.0
│ ├── lockfile@0.2.1
│ ├── lru-cache@2.0.4
│ ├── minimatch@0.2.6
│ ├── mkdirp@0.3.4
│ ├── node-gyp@0.7.0
│ ├── nopt@2.0.0
│ ├─┬ npm-registry-client@0.2.9
│ │ └── couch-login@0.1.15
│ ├─┬ npmconf@0.0.16
│ │ └─┬ config-chain@1.1.2
│ │   └── proto-list@1.2.2
│ ├── npmlog@0.0.2
│ ├── once@1.1.1
│ ├── opener@1.3.0
│ ├── osenv@0.0.3
│ ├─┬ read@1.0.4
│ │ └── mute-stream@0.0.3
│ ├── read-installed@0.0.3
│ ├── read-package-json@0.1.7
│ ├── request@2.9.203
│ ├── retry@0.6.0
│ ├── rimraf@2.0.2
│ ├── semver@1.1.0
│ ├── slide@1.1.3
│ ├── tar@0.1.13
│ ├── uid-number@0.0.3
│ └── which@1.0.5
└─┬ tower@0.4.2-20
  ├── accounting@0.3.2
  ├── ansi@0.1.2
  ├── async@0.1.22
  ├─┬ commander@1.0.5
  │ └── keypress@0.1.0
  ├─┬ connect@2.6.1
  │ ├── bytes@0.1.0
  │ ├── cookie@0.0.4
  │ ├── cookie-signature@0.0.1
  │ ├── debug@0.7.0
  │ ├── formidable@1.0.11
  │ ├── pause@0.0.1
  │ └─┬ send@0.1.0
  │   ├── mime@1.2.6
  │   └── range-parser@0.0.4
  ├── crc@0.2.0
  ├── ejs@0.8.3
  ├── ember-metal-node@1.0.0-pre
  ├── ember-runtime-node@1.0.0-pre
  ├── ember-states-node@1.0.0-pre
  ├─┬ express@3.0.0
  │ ├── commander@0.6.1
  │ ├─┬ connect@2.6.0
  │ │ ├── bytes@0.1.0
  │ │ ├── formidable@1.0.11
  │ │ ├── pause@0.0.1
  │ │ └─┬ send@0.0.4
  │ │   └── mime@1.2.6
  │ ├── cookie@0.0.4
  │ ├── debug@0.7.0
  │ ├── methods@0.0.1
  │ ├── mkdirp@0.3.3
  │ ├── range-parser@0.0.4
  │ └─┬ send@0.1.0
  │   └── mime@1.2.6
  ├── fresh@0.1.0
  ├── geolib@1.2.2
  ├── gm@1.4.2
  ├─┬ grunt-contrib-less@0.3.2
  │ ├── grunt-lib-contrib@0.3.0
  │ └── less@1.3.1
  ├── inflection@1.2.3
  ├── mime@1.2.7
  ├── mint@0.3.5
  ├── moment@1.7.2
  ├── node-uuid@1.4.0
  ├── qs@0.5.1
  ├─┬ superagent@0.9.7
  │ ├── cookiejar@1.3.0
  │ ├── emitter-component@0.0.5
  │ ├── formidable@1.0.9
  │ ├── methods@0.0.1
  │ ├── mime@1.2.5
  │ └── qs@0.4.2
  ├── temp@0.4.0
  ├─┬ term-css@1.0.0
  │ └─┬ css@1.0.1
  │   ├─┬ css-parse@1.0.1
  │   │ └── debug@0.7.0
  │   └── css-stringify@1.0.1
  ├── underscore@1.4.2
  ├── underscore.string@2.3.0
  ├── URIjs@1.7.4
  ├─┬ useragent@1.1.0
  │ ├── request@2.9.202
  │ ├── semver@1.0.14
  │ └── yamlparser@0.0.2
  ├── validator@0.4.13
  ├── which@1.0.5
  └── wrench@1.3.9

And here are my local:

$ npm list
gdg@0.1.0 /Users/jridgway/gdg
├── async@0.1.22
├── chai@1.3.0
├── chokidar@0.4.0
├─┬ cli-table@0.2.0
│ └── colors@0.3.0
├── coffee-script@1.4.0
├─┬ coffeecup@0.3.17
│ ├── coffee-script@1.3.3
│ ├── optparse@1.0.3
│ ├─┬ stylus@0.27.2
│ │ ├── cssom@0.2.5
│ │ ├── debug@0.7.0
│ │ └── mkdirp@0.3.4
│ └── uglify-js@1.2.6
├── ejs@0.8.3
├── Faker@0.1.3
├── fibers@0.6.9
├─┬ grunt-contrib@0.3.0
│ ├─┬ grunt-contrib-clean@0.3.1
│ │ ├── grunt-lib-contrib@0.3.0
│ │ └─┬ rimraf@2.0.2
│ │   └── graceful-fs@1.1.14
│ ├─┬ grunt-contrib-coffee@0.3.2
│ │ ├── coffee-script@1.3.3
│ │ └── grunt-lib-contrib@0.3.0
│ ├─┬ grunt-contrib-compress@0.3.2
│ │ ├── archiver@0.1.0
│ │ ├─┬ fstream@0.1.19
│ │ │ ├── graceful-fs@1.1.14
│ │ │ ├── inherits@1.0.0
│ │ │ └── mkdirp@0.3.4
│ │ ├── grunt-lib-contrib@0.3.0
│ │ ├─┬ rimraf@2.0.2
│ │ │ └── graceful-fs@1.1.14
│ │ └─┬ tar@0.1.13
│ │   ├── block-stream@0.0.6
│ │   └── inherits@1.0.0
│ ├─┬ grunt-contrib-copy@0.3.2
│ │ └── grunt-lib-contrib@0.3.0
│ ├─┬ grunt-contrib-handlebars@0.3.2
│ │ ├── grunt-lib-contrib@0.3.0
│ │ └─┬ handlebars@1.0.7
│ │   ├─┬ optimist@0.3.5
│ │   │ └── wordwrap@0.0.2
│ │   └── uglify-js@1.2.6
│ ├─┬ grunt-contrib-jade@0.3.1
│ │ ├── grunt-lib-contrib@0.3.0
│ │ └─┬ jade@0.27.6
│ │   ├── commander@0.6.1
│ │   └── mkdirp@0.3.4
│ ├─┬ grunt-contrib-jst@0.3.1
│ │ ├── grunt-lib-contrib@0.3.0
│ │ └── underscore@1.3.3
│ ├─┬ grunt-contrib-mincss@0.3.1
│ │ ├─┬ clean-css@0.4.2
│ │ │ └─┬ optimist@0.3.5
│ │ │   └── wordwrap@0.0.2
│ │ ├── grunt-lib-contrib@0.3.0
│ │ └─┬ gzip-js@0.3.1
│ │   ├── crc32@0.2.2
│ │   └── deflate-js@0.2.2
│ ├─┬ grunt-contrib-requirejs@0.3.3
│ │ ├── grunt-lib-contrib@0.3.0
│ │ └── requirejs@2.1.1
│ └─┬ grunt-contrib-yuidoc@0.3.2
│   ├── grunt-lib-contrib@0.3.0
│   └─┬ yuidocjs@0.3.30
│     ├─┬ express@2.5.11
│     │ ├─┬ connect@1.9.2
│     │ │ └── formidable@1.0.11
│     │ ├── mime@1.2.4
│     │ ├── mkdirp@0.3.0
│     │ └── qs@0.4.2
│     ├── graceful-fs@1.1.14
│     ├─┬ minimatch@0.1.5
│     │ └── lru-cache@1.0.6
│     ├── node-markdown@0.1.1
│     ├── rimraf@2.0.2
│     └─┬ yui@3.7.3
│       └── request@2.9.202
├─┬ grunt-contrib-less@0.3.2
│ └── grunt-lib-contrib@0.3.0
├─┬ grunt-contrib-stylus@0.3.1
│ ├── grunt-lib-contrib@0.3.0
│ ├── nib@0.8.2
│ └─┬ stylus@0.29.0
│   ├── cssom@0.2.5
│   ├── debug@0.7.0
│   └── mkdirp@0.3.4
├── gzip@0.1.0
├─┬ knox@0.3.1
│ └── mime@1.2.7
├─┬ kue@0.4.0
│ ├─┬ express@2.5.10
│ │ ├─┬ connect@1.9.2
│ │ │ └── formidable@1.0.11
│ │ ├── mime@1.2.4
│ │ ├── mkdirp@0.3.0
│ │ └── qs@0.4.2
│ ├─┬ jade@0.26.3
│ │ ├── commander@0.6.1
│ │ └── mkdirp@0.3.0
│ ├── nib@0.5.0
│ ├─┬ redis@0.7.2
│ │ └── hiredis@0.1.14
│ ├─┬ reds@0.1.4
│ │ └─┬ natural@0.0.69
│ │   ├── apparatus@0.0.6
│ │   ├── sylvester@0.0.21
│ │   └── underscore@1.4.2
│ └─┬ stylus@0.27.2
│   ├── cssom@0.2.5
│   ├── debug@0.7.0
│   └── mkdirp@0.3.4
├── less@1.3.1
├─┬ mocha@1.6.0
│ ├── commander@0.6.1
│ ├── debug@0.7.0
│ ├── diff@1.0.2
│ ├── growl@1.5.1
│ ├─┬ jade@0.26.3
│ │ └── mkdirp@0.3.0
│ ├── mkdirp@0.3.3
│ └── ms@0.3.0
├─┬ mongodb@1.1.11
│ └── bson@0.1.5
├─┬ nodemailer@0.3.28
│ ├─┬ mailcomposer@0.1.21
│ │ ├── mime@1.2.7
│ │ └─┬ mimelib@0.2.7
│ │   ├── addressparser@0.1.3
│ │   └─┬ encoding@0.1.4
│ │     ├── iconv@1.2.3
│ │     └── iconv-lite@0.2.5
│ ├─┬ optimist@0.3.5
│ │ └── wordwrap@0.0.2
│ └─┬ simplesmtp@0.1.25
│   ├── rai@0.1.6
│   └─┬ xoauth2@0.1.3
│     └─┬ request@2.11.4
│       ├─┬ form-data@0.0.3
│       │ ├── async@0.1.9
│       │ └─┬ combined-stream@0.0.3
│       │   └── delayed-stream@0.0.5
│       └── mime@1.2.7
├─┬ sinon@1.5.0
│ └─┬ buster-format@0.5.5
│   └── buster-core@0.6.4
├─┬ socket.io@0.9.10
│ ├── policyfile@0.0.4
│ └─┬ redis@0.7.2
│   └── hiredis@0.1.14
├─┬ socket.io-client@0.9.10
│ ├─┬ active-x-obfuscator@0.0.1
│ │ └── zeparser@0.0.5
│ ├── uglify-js@1.2.5
│ ├─┬ ws@0.4.22
│ │ ├── commander@0.6.1
│ │ ├── options@0.0.3
│ │ └── tinycolor@0.0.1
│ └── xmlhttprequest@1.4.2
├─┬ stylus@0.30.1
│ ├── cssom@0.2.5
│ ├── debug@0.7.0
│ └── mkdirp@0.3.4
├─┬ superagent@0.9.7
│ ├── cookiejar@1.3.0
│ ├── emitter-component@0.0.5
│ ├── formidable@1.0.9
│ ├── methods@0.0.1
│ ├── mime@1.2.5
│ └── qs@0.4.2
├─┬ tower@0.4.2-20
│ ├── accounting@0.3.2
│ ├── ansi@0.1.2
│ ├─┬ commander@1.0.5
│ │ └── keypress@0.1.0
│ ├─┬ connect@2.6.1
│ │ ├── bytes@0.1.0
│ │ ├── cookie@0.0.4
│ │ ├── cookie-signature@0.0.1
│ │ ├── debug@0.7.0
│ │ ├── formidable@1.0.11
│ │ ├── pause@0.0.1
│ │ └─┬ send@0.1.0
│ │   ├── mime@1.2.6
│ │   └── range-parser@0.0.4
│ ├── crc@0.2.0
│ ├── ember-metal-node@1.0.0-pre
│ ├── ember-runtime-node@1.0.0-pre
│ ├── ember-states-node@1.0.0-pre
│ ├─┬ express@3.0.0
│ │ ├── commander@0.6.1
│ │ ├─┬ connect@2.6.0
│ │ │ ├── bytes@0.1.0
│ │ │ ├── formidable@1.0.11
│ │ │ ├── pause@0.0.1
│ │ │ └─┬ send@0.0.4
│ │ │   └── mime@1.2.6
│ │ ├── cookie@0.0.4
│ │ ├── debug@0.7.0
│ │ ├── methods@0.0.1
│ │ ├── mkdirp@0.3.3
│ │ ├── range-parser@0.0.4
│ │ └─┬ send@0.1.0
│ │   └── mime@1.2.6
│ ├── fresh@0.1.0
│ ├── geolib@1.2.2
│ ├── gm@1.4.2
│ ├── inflection@1.2.3
│ ├── mime@1.2.7
│ ├── mint@0.3.5
│ ├── moment@1.7.2
│ ├── node-uuid@1.4.0
│ ├── qs@0.5.1
│ ├── temp@0.4.0
│ ├─┬ term-css@1.0.0
│ │ └─┬ css@1.0.1
│ │   ├─┬ css-parse@1.0.1
│ │   │ └── debug@0.7.0
│ │   └── css-stringify@1.0.1
│ ├── underscore@1.4.2
│ ├── underscore.string@2.3.0
│ ├── URIjs@1.7.4
│ ├─┬ useragent@1.1.0
│ │ ├── request@2.9.202
│ │ ├── semver@1.0.14
│ │ └── yamlparser@0.0.2
│ └── validator@0.4.13
├── uglify-js@1.3.4
├── which@1.0.5
└── wrench@1.3.9
jridgway commented 11 years ago

I installed tower with npm install, not link. I am not using a github clone, however, I did at one point try installing (npm install) from the github master branch with no luck. I'm currently using the npm install tower -g method.

termsurfhare commented 11 years ago

Hmm... everything looks fine.

I am using:

  • coffee-script 1.3.3 (it's now 1.4.0 which you're using). Upgrading mine didn't change anything, still works.
  • grunt 0.3.16
  • node 0.8.2

None of these things should affect it.

So it looks like the original error this issue was for is because the App.User model doesn't exist. This may be happening because the controller code is being required before the model code. I'd make sure the models are loaded before the controller just so we can scratch this off the list, but I don't think this is the issue.

The error occurs in the @scope method which tries to get the App.User class to setup data syncing stuff. But if the model isn't yet required, that could cause the error.

Another thing it could be... Try logging the value of @metadata() in the controller on startup:

# app/controllers/server/usersController.coffee
# change this:
class App.UsersController extends App.Application
  @scope 'all'

# to this:
class App.UsersController extends App.Application

console.log App.UsersController.metadata()

Also do the same thing in the client controller, just to make sure the client controller isn't being required (it shouldn't be being required at all):

# app/controllers/client/usersController.coffee
class App.UsersController extends App.Application

console.log App.UsersController.metadata()

It could be that the value of metadata().resourceType is blank. This is what App.UsersController.metadata() should look like (params/callback may be different, but the strings are what are important):

{ className: 'UsersController',
  resourceName: 'user',
  resourceType: 'User',
  collectionName: 'users',
  params: {},
  renderers: {},
  mimes: { json: {}, html: {} },
  callbacks: { action: { before: [Object], after: [] } },
  helpers: [],
  belongsTo: [],
  subscriptions: [],
  layout: 'application',
  scopes: {},
  scopeNames: [] }

If metadata().resourceType is different, I think this is because of a coffee-script compilation problem (I have run into your issue before). To test that the coffee-script version of the file is correct... OH! I think I know what it is now.

Tower has coffee-script extensions that basically allow coffee-script's class declaration to be translated to Ember's class system (one of these other issues goes into detail on how/why this is necessary).

The problem you are facing may be because coffee-script is installed in your app directly and in tower's source. This is a problem because in the tower module, it is overriding its own coffee-script with the extensions, but that may be a different coffee-script than what your app is using:

./node_modules/coffee-script
./node_modules/tower/node_modules/coffee-script

If your app calls require('coffee-script') anywhere, it will cause NPM to use the ./node_modules/coffee-script version instead of the ./node_modules/tower/node_modules/coffee-script one. If that happens then in tower/blob/master/coffee-inheritance.js, which is required from tower/blob/master/index.js, will only be applied to the coffee-script used in ./node_modules/tower, but not in your app. However, if your app doesn't require coffee-script directly, then the coffee-script used in Tower will be used everywhere. Hope that's not too confusing.

Anyway, try removing the coffee-script module in your app (delete ./node_modules/coffee-script). Let me know how that goes.

thehydroimpulse commented 11 years ago

Now I can see how coffee-script really does complicate everything (while also simplifying it).

br8kpoint commented 11 years ago

after deleting ./node_modules/coffee-script and running cake watch I get

$ cake watch
{ [Error: Cannot find module 'coffee-script'] code: 'MODULE_NOT_FOUND' }
{ [Error: Cannot find module 'coffee-script'] code: 'MODULE_NOT_FOUND' }
Default database not set, using Memory store
Loading "grunt.coffee" tasks and helpers...
ERROR
>> Error: Constant 'App.' wasn't found
<WARN> Task "start" not found. Use --force to continue. </WARN>

Aborted due to warnings.

and running node server gives

$ node server
{ [Error: Cannot find module 'coffee-script'] code: 'MODULE_NOT_FOUND' }
   info  - socket.io started
Tower development server listening on port 3000

/home/mike/Work/callcenter_tower/node_modules/tower/lib/tower-support/shared/shared.js:242
        throw new Error("Constant '" + string + "' wasn't found");
              ^
Error: Constant 'App.' wasn't found
    at _.extend.constant (/home/mike/Work/callcenter_tower/node_modules/tower/lib/tower-support/shared/shared.js:242:15)
    at _.extend.constant (/home/mike/Work/callcenter_tower/node_modules/tower/lib/tower-support/shared/shared.js:240:22)
    at Function.Tower.ControllerScopes.ClassMethods.scope (/home/mike/Work/callcenter_tower/node_modules/tower/lib/tower-controller/shared/scopes.js:13:25)
    at /home/mike/Work/callcenter_tower/app/controllers/server/usersController.coffee:27:21
    at Object.<anonymous> (/home/mike/Work/callcenter_tower/app/controllers/server/usersController.coffee:31:5)
    at Object.<anonymous> (/home/mike/Work/callcenter_tower/app/controllers/server/usersController.coffee:33:4)
    at Module._compile (module.js:449:26)
    at Object.require.extensions..coffee (/home/mike/Work/callcenter_tower/node_modules/coffeecup/node_modules/coffee-script/lib/coffee-script/coffee-script.js:22:21)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

So that did not fix the issue

jridgway commented 11 years ago

Same here. I did notice though that coffee-script was installed multiple times at 1.3.3 and 1.4.0. It looks like Tower wants both somehow. I forced it so that it was using 1.3.3 both in my app and in Tower but no luck. I'll keep swinging. Thanks for all the feedback!

jridgway commented 11 years ago

This is what I get from cake build with console.log App.UsersController.metadata() in both the server and client users controllers:

$ cake build
Default database not set, using Memory store
{ className: 'Controller',
  resourceName: '',
  resourceType: '',
  collectionName: '',
  params: 
   { page: 
      { controller: undefined,
        key: 'page',
        attribute: 'page',
        modelName: undefined,
        exact: false,
        default: undefined,
        allowNegative: false,
        allowFloat: true,
        allowRange: false },
     limit: 
      { controller: undefined,
        key: 'limit',
        attribute: 'limit',
        modelName: undefined,
        exact: false,
        default: undefined,
        allowNegative: false,
        allowFloat: true,
        allowRange: false },
     sort: 
      { controller: undefined,
        key: 'sort',
        attribute: 'sort',
        modelName: undefined,
        exact: false,
        default: undefined },
     fields: 
      { controller: undefined,
        key: 'fields',
        attribute: 'fields',
        modelName: undefined,
        exact: false,
        default: undefined },
     createdAt: 
      { controller: undefined,
        key: 'createdAt',
        attribute: 'createdAt',
        modelName: undefined,
        exact: false,
        default: undefined },
     updatedAt: 
      { controller: undefined,
        key: 'updatedAt',
        attribute: 'updatedAt',
        modelName: undefined,
        exact: false,
        default: undefined } },
  renderers: { text: [Function], json: [Function] },
  mimes: { json: {}, html: {} },
  callbacks: { action: { before: [Object], after: [] } },
  helpers: [],
  belongsTo: [],
  subscriptions: [],
  layout: 'application',
  scopes: {},
  scopeNames: [] }
jridgway commented 11 years ago

I think you're right @viatropos about coffee-inheritance.js, I just don't know how to go about fixing it.

jridgway commented 11 years ago

Hey, I finally worked through it by explicitly requiring coffee-script to version 1.3.3 in packages.json rather than requiring any version >= 1.3.3: "coffee-script": "= 1.3.3",

kennu commented 11 years ago

I can confirm jridgway's solution. A generated virgin app starts working when you rm -rf node_modules, change the package.json coffee-script dependency to "= 1.3.3", and rerun npm install.

stevenrace commented 11 years ago

Howdy,

Just bringing this back up, as I get the above error when starting a new Towerjs project within Linux. The above fix of forcing coffee-script to =1.3.3 within package.json works.