Quantcast
Channel: Import external class in nodejs - Stack Overflow
Browsing all 4 articles
Browse latest View live

Answer by Leonardo Buscemi for Import external class in nodejs

Already tried. Gives me error: Uncaught SyntaxError: Unexpected token importDid you try the require syntaxt?const db = require('./db');

View Article



Answer by D-Money for Import external class in nodejs

If you're using ES6/ES2015 you can import the class:db.js:class sqlConn { ...}export { sqlConn as default }main.html:import sqlConn from './path_to_file');var obj = new sqlConn(...);

View Article

Answer by Arkerone for Import external class in nodejs

Pass the good path on the required function :var sqlConn = require('./db'); // or other path if the file db.js isn't on the same folderbut I see main.html, you try to use a node.js code into html?

View Article

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...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images