Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6015293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:48:56+00:00 2026-05-23T02:48:56+00:00

In CofeeScript I am creating a global object by doing this: window.App = init

  • 0

In CofeeScript I am creating a global object by doing this:

window.App = 
  init : ->
    ...

Running coffee -w app.coffee complains window is not defined and doesn’t rewrite the app.js file.

However, running coffee -c app.coffee compiles without a problem.
How can I get coffee -w to accept global window?

CoffeeScript version is 1.1.1 (from coffee -v)

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:48:57+00:00Added an answer on May 23, 2026 at 2:48 am

    If you want to watch a file and have it compiled you need to do:

    coffee -wc file.coffee

    Using only the -w flag causes coffee to just run the script when it changes, as if you had run:

    coffee file.coffee

    In regards to the window is not defined error, if you want to make your script runnable both in a browser and in node.js, then you can do this:

    root = exports ? this
    
    class Thing
      constructor: (@name) ->
      whoAreYou: ->
        alert @name
    
    root.Thing = Thing
    

    Another useful flag combination is -wp which just pipes the compile javascript to standard out each time you make a change to the file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking at this CoffeeScript tutorial : http://jashkenas.github.com/coffee-script/ I don't quite see what the Splats
There has been a lot of discussion over this ability (such as in this
I'm having some trouble creating functions with CoffeeScript, I guess I've missed something. For
Trying to understand how CoffeeScript instance and class variable works I came with this
I'm trying to convert this code from Javascript to CoffeeScript: for (var i =
I have the following method on a backbone view defined in coffeescript: saveObservation: =>
I've been looking at CoffeeScript and I'm not understanding how you would write code
The coffeescript compiler is, for some reason, wrapping all of my .coffee files in
I have a working coffeescript/backbone idiom that looks like this: SidebarWidgets = ((() ->
I'm trying to convert a function from Javascript to CoffeeScript. This is the code:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.