0

I'm trying to configure Emacs with Tern.js to use AngularJS in it. When add angular to .tern-project like:

{
  "plugins": {
    "node": {
    },
    "angular": {
    }
  }
}

and type app.| I get ReferenceError in Angular itself printed in minibuffer:

/my/project/home/angular.js:26307
})(window, document);
   ^
ReferenceError: window is not defined
    at Object.<anonymous> (/my/project/home/angular.js:26307:4)
    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 Module.require (module.js:364:17)
    at require (module.js:380:17)
    at loadPlugins (/usr/local/lib/node_modules/tern/bin/tern:111:15)
    at startServer (/usr/local/lib/node_modules/tern/bin/tern:136:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/tern/bin/tern:132:14)
)

Does anyone have some experience with this or advice?

  • 1
    A shot in the dark: maybe, similar to jslint it could understand /* global: window */ comment in the file? The problem is that you must be trying to run this in a NodeJS or similar environment (outside of a browser), which doesn't define window and document variables. However, even if you will get Tern to ignore these, this means that any code that actually uses them will fail. Another option would be to search for a JavaScript library which imitates window and document API. – wvxvw May 19 '15 at 11:55
  • See if github.com/tmpvar/jsdom will help. – wvxvw May 19 '15 at 11:57
1

I believe the window object is provided by the browser lib, so you'll need something like:

{
  "libs": [
    "browser"
  ],
  "plugins": {
    "node": {},
    "angular": {}
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.