This post assumes you have already done these steps.
To have intelligent JavaScript support across files in Spacemacs, we need to let Tern know which libraries and files we're using.
Create a JSON file named .tern-project in your project's root directory:
{
"libs" : [
"browser",
"jquery"
],
"loadEagerly": [ "js/*.js", "*.js" ],
"plugins" : {
"commonjs" : {},
"node" : {},
"requirejs" : {},
"node_resolve" : {}
}
}
Above, we're telling Tern to:
Parts of the .tern-project file above are from this helpful post.
If you're using NodeJS, you'll want to setup js2-mode so it knows what module means in your JavaScript. You might get similar errors if you're using other plugins and haven't set certain variables in your .spacemacs file.
In the Tern documentation.
SPACE m g g. See more shortcuts in the JavaScript layer documentation.
Leave a comment