javascript - Bootstrap.js is not transpiled in time in sailsJS -


i writing backend in sails js using es6/7 , have defined class performs background task.

now this stackoverflow post have learned background tasks should initiated @ config/bootstrap.js. put following inside file:

import backgroundservice '../api/services/backgroundservice.js';  module.exports.bootstrap = function(cb) {   backgroundservice= new backgroundservice();   backgroundservice.run();    cb(); }; 

now i'm getting typicall transpiler erros like:

  import backgroundservice '../api/services/backgroundservice.js';   ^^^^^^ syntaxerror: unexpected reserved word[...] 

or, when replace import require:

typeerror: cannot call class function  

(referring instantiation of backgroundservice class)

this indicates files either not transpiled in time or @ all.
couldn't find solution yet.

any ideas?

not sure if problem still exists, it does: nodejs doesn't support es6 import. can either go old way

const backgroundservice = require('../api/services/backgroundservice.js'); 

or use babel. sails i'd suggest sails babel

note: depending on app's globals configuration don't need import services @ all. if have globals activated can directly call backgroundservice


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -