Is there a way to import npm packages in custom modules? I would really love to use node-osascript to execute some AppleScript … Any ideas anyone?
Many thanks in advance!
Is there a way to import npm packages in custom modules? I would really love to use node-osascript to execute some AppleScript … Any ideas anyone?
Many thanks in advance!
No it’s not possible. Currently the custom module’s version of require()
only allows running simple js modules, but not loading any node native module. I’ve been considering opening this for a while but haven’t fully made my mind yet.
I see! This would be absolutely great because it would open a whole new world of possibilities …
I’ve come to think it’s not reasonable to try sandboxing the custom module entirely (currently it’s actually even possible to break the sandbox and require native package); I’m currently adding a requireNative()
function that does what require()
does in a regular node application. It shall indeed open a whole world of possibilities… and risks for those who’d run custom modules from untrusted sources (but the flaw is already here anyway, better document it).
Great!!!
v1.8.0 is currently building / uploading, the documentation has been updated.
Thank you so much! It works like a charm!! I can now execute applescript with node-osascript to send key commands to my applications. W-O-N-D-E-R-F-U-L!