Node-powershell

Hi, I am trying use node-powershell to get some local data, but am stuck. Maybe it’s not possible? .

I can get the require to work, but then can’t seem to get an object. Or, it suggests I have instantiated a class (‘TypeError: Cannot call a class as a function’), and I am unable to use the ‘new’ directive (‘TypeError: spawn is not a function’).

Please have a look and comment if you like. Thanks.

Hi!

Unfortunately, node-powershell isn’t going to work with Observable - it’s a module that runs only in Node.js and as part of a server or on the command-line. Observable is a web environment and runs code on the web in browsers - so it won’t have Node.js built-in modules like spawn or the ability that that module has to spawn processes.

Like other web apps, Observable won’t be able to access your local data by a script alone - which is a good thing, because if it did, websites would gleefully steal your data :slight_smile:

To load data, check out Mike’s Introduction to Data notebook - which shows how to upload data to the web and load it in a notebook - and check out the DOM.input(‘file’) method in the standard library notebook, which lets you add a file input to a notebook and read the results.

Thanks tom.
I thought I’ve had some success previously using node modules in browser, but probably no spawning.
Can I trigger ‘DOM.input(“file”)’ on a timed function?
Eventually I will get the data by websockets, but I was trying to set up something more immediate.

I ended up using the websocket in observable (kudos to Chris Price), connecting locally to a commandline utility called websocketd.

Seems perfect for my needs at this time. Well worth a look.