MiguelCastillo / Brackets-Ternific

Javascript hinting and refactoring powered by Tern
Other
79 stars 20 forks source link

Uncaught TypeError: Cannot read property 'knownModules' of undefined #78

Closed ficristo closed 9 years ago

ficristo commented 9 years ago

I tried to enable the node plugin but I get this error: Uncaught TypeError: Cannot read property 'knownModules' of undefined Do you know what could be?

It sufficient to have a .tern-project file at the root of the project like this:

{
    "plugins": {
        "node": {}
    }
}
MiguelCastillo commented 9 years ago

I just reproduced the issue, so that made it easier to figure what the issue is. You would need to explicitly tell tern what other stuff the node plugin depends on. I got it working with a very bare minimum config of

{
  "plugins": {
    "modules": {},
    "commonjs": {},
    "node": {}
  }
}

However, I would add the extra plugin node_resolve. This is what my config looks like:

{
  "libs": [
    "./libs/tern/defs/reserved",
    "./libs/tern/defs/lodash",
    "browser",
    "chai",
    "ecma5",
    "ecma6",
    "browser",
    "jquery"
  ],
  "loadEagerly": [],
  "async": true,
  "plugins": {
    "modules": {},
    "node_resolve": {},
    "commonjs": {},
    "node": {}
  }
}

Here is some information on the node plugin for tern. http://ternjs.net/doc/manual.html#plugin_node

ficristo commented 9 years ago

I had read the information and thought that adding node plugin implied that modules, node_resolve and commonjs were also added. I explicitly added the plugins and now don't see the error anymore. Thank you for the answer.