1

I'm not sure if this is possible without some serious tweaking but is it possible to run javascript plugins server side with node...

more specifically

I would like to run the dymo javascript sdk from node (the printer is attached to the server)

that way any device can print from the server.

I have tried using https://github.com/tojocky/node-printer as a workaround however it doesnt work in my situation (works with my laserjet though)

I have tried just requiring the file that failed miserably.

if this is possible can you just point me in the right direction I have been searching the google and even been corresponding with dymo developers however I havent gotten much help from them.

so the simplest way to put it: Can you run clientside javascript plugins from server side? if not is there a way to write a middleware that will act as a bridge?

here is the plugin file(before I modify it more): http://irwinproject.com/jss/Dymo.js

its a bunch of craziness. I am trying to modify it to work as a module

UPDATE: I have gotten most of the functions running properly however I have hit a bit of a snag their sdk requires active x which I dont understand because I'm on a mac and it works

can someone explain to me how active x can function client side on a mac? (i thought that was windows only) and also is there anyway to implement the same framework(activex or other) through node

if I understand this correctly active x is used as an abstraction layer between javascript and hardware

Snymax
  • 357
  • 4
  • 18
  • how requiring the file failed? – Santiago Rebella Aug 26 '14 at 16:30
  • 1
    ... it didnt really fail(I was able to require it) but the functions are not exposed. I tried adding them to an object however they didnt function properly when I tried that. (im not sure if it was lack of access to active x or if I have to expose them differently then just adding the function to an objects property – Snymax Aug 26 '14 at 17:07

1 Answers1

0

You have to return your object or functions with module.exports, also try to verify you are requiring your file with . so node knows is a local module.

Check this SO post with a highly upvoted answer : What is the purpose of Node.js module.exports and how do you use it?

module.exports is the object that's actually returned as the result of a require call.

The exports variable is initially set to that same object (i.e. it's a shorthand "alias"), so in the module code you would usually write something like this....

Community
  • 1
  • 1
Santiago Rebella
  • 2,399
  • 2
  • 22
  • 29
  • I am going to post the raw file so you can see what im working with. I understand how to use the module.exports. my problem is the functions arent a part of an object so I have to modify the file so they are right now all the functions are wrapped in a massive () ex:('the file contents'). So before I went through the trouble of trying to modify it I was trying to see if there was another way to use plugins that were made for client side javascript in node – Snymax Aug 26 '14 at 17:18
  • I have require an array of objects from a local file without the exports if it helps, but not functions, I think should be an alternative without modifying your source, are you requiring with the dot? – Santiago Rebella Aug 26 '14 at 17:24
  • right now I have a folder in node_modules called dymo and i have made a package.json and index.js(this contains a copy and past of the sdk) and then in my router file I have require('dymo'); – Snymax Aug 26 '14 at 17:28