timboudreau / nb-nodejs

NodeJS support for NetBeans, originally hosted on netbeans.org
MIT License
91 stars 12 forks source link

The global variable 'require' is not declared #14

Closed su9204 closed 10 years ago

su9204 commented 10 years ago

var http = require('http');

The IDE (netbeans 8.0 beta) will show a warning that "The global variable 'require' is not declared". Any solutions? Thank you!

timboudreau commented 10 years ago

There may be some stuff possible, but really it needs some infrastructure on the NetBeans side to make that work. Basically, Node, under the hood, generates a function (require, module, exports, ...) and wraps that around each Node module when it loads them.

There needs to be a way to tell NetBeans that (and faking out the InputStream from the file will screw up everything that needs file offsets - the Javascript parser needs to be told to do that).

I'll get in touch with the guy doing Javascript support for NetBeans and see if he has any suggestions - but what I'm saying is, I'm not sure there is much that a plugin can do without very specific support from the Javascript parser in the IDE.

su9204 commented 10 years ago

May be try something like using the typestub https://github.com/borisyankov/DefinitelyTyped

Also What I noticed is if all statements involved require('...') is on the right hand of an assignment (instead simply require('something').doSomething()), it does not show warning.

timboudreau commented 10 years ago

Closing as a duplicate of #2 - if we get code completion working, this will fall out of it.