n-riesco / ijavascript

IJavascript is a javascript kernel for the Jupyter notebook
Other
2.18k stars 187 forks source link

use $$ to install npm packages #140

Open n-riesco opened 6 years ago

n-riesco commented 6 years ago

I need to document how to install an npm package so that it can be requested during an IJavascript session.

Alternatively, $$ could provide a function; e.g: $$.npm(), $$.yarn() or just $$.exec() to run a shell command in the session working directory.

guy1ziv2 commented 6 years ago

Is there any progress on this? Did you find out how to nstall an npm package during a IJavascript session?

freiit commented 6 years ago

This here works for me as a workaround - it pollutes the global file system.

$$.async(); require('child_process').exec('npm install node-fetch', (f, o, e) => $$.done({ f, o, e }))
n-riesco commented 6 years ago

@freiit This should work: child_process.execSync("npm install node-fetch").

You may also find useful the discussion in #118 .


it pollutes the global file system

What do you mean by that?


Is there any progress on this?

I'm not working on this issue. Last time I checked npm and yarn didn't expose an API to JS. And I'm not convinced defining something like the below would be really useful:

$$.npm = function(args) {
    return child_process.execSync("npm " + args);
};