Access Filesystem require("fs") and Shell within custom plugin



I’m creating a custom plugin and want to access the system resources like filesystem and shell within my plugin code.
I already discovered the appropriate node.js plugins for that task.

My issue is that the require(‘fs’) returns an empty object. For example:

'use strict';

var assign = Object.assign;

function ClientPlugin(eventBus, canvas) {
    // this variable is empty. Has no functions in it.
    var fileSystem = require('fs');

ClientPlugin.$inject = [ 'eventBus', 'canvas' ];

module.exports = {
  __init__: [ 'clientPlugin' ],
  clientPlugin: [ 'type', ClientPlugin ]

Am I doing it wrong? Is there some trick to obtain the right object?

Thank you for your advice.


have you tried using window.require instead of only require?


For everyone ending up in this thread a bit of warning.

We do not consider file system access for client-side plug-ins a public feature and keep it open to remove that functionality any time.

Rationale: It can be a potential security threat.

closed #4