Guest User

Untitled

a guest
Sep 25th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. I was able to solve below using specifying file name in assets
  2.  
  3. webapp.js
  4. const serverType = opts.serverType || 'http';
  5. const serverImpl = require(serverType); -> variable inside require
  6.  
  7. package.json
  8. "assets": "lib/server/webapp.js"
  9.  
  10. But Im stuck in below
  11.  
  12. index.js
  13.  
  14. require(TOPIC_SETTINGS[argv.topic].backend);
  15. require(`processors/${argv.topic}/processor.${processorModule}`)(dbClient));
  16.  
  17. package.json
  18. "assets":"index.js"
  19.  
  20. getting below error
  21.  
  22. after i taken out dynamic part of the code
  23.  
  24. const temp1 = './lib/' + TOPIC_SETTINGS[argv.topic].backend + '.js'
  25. const DbClient = require(temp1);
  26.  
  27.  
  28. Warning Cannot resolve 'temp1'
  29. /home/nilesh/index.js
  30. Dynamic require may fail at run time, because the requested file
  31. is unknown at compilation time and not included into executable.
  32. Use a string literal as an argument for 'require', or leave it
  33. as is and specify the resolved file name in 'scripts' option.
Add Comment
Please, Sign In to add comment