Quantcast
Viewing latest article 4
Browse Latest Browse All 4

Import external class in nodejs

i´v got a class which i want to export and import it in another file.

//db.js    class sqlConn {      constru....}modules.exports = sqlConn;

I tried to import it, but that doenst worked for me...

//main.htmlvar sqlConn = require('path_to_file');var obj = new sqlConn(...);

That gives me following error:

Uncaught Error: Cannot find module 'path_to_file'

can someone help me?

Edit on some answers

I´m using electron with node.js
and my class is laying on an html server.

Also i´m trying to import all in an index.html to sahre an electron.exe which imports all with ajax.


Viewing latest article 4
Browse Latest Browse All 4

Trending Articles