pixiedust / pixiedust_node

Jupyter magic to allow Node.js code to run in a notebook
https://medium.com/ibm-watson-data-lab/running-node-js-notebooks-in-watson-studio-a8f6545d8299
Apache License 2.0
213 stars 24 forks source link

Wrong working directory used when running node #4

Closed DTAIEB closed 6 years ago

DTAIEB commented 7 years ago

The node subprocess is launched using the wrong cwd (see https://github.com/ibm-watson-data-lab/pixiedust_node/blob/master/pixiedust_node/node.py#L27) it should match the npm command which is using the current working directory.

I think we should have both node and npm using the central working directory e.g. PIXIEDUST_HOME/node.

Note: you can get the PIXIEDUST_HOME directory using the Environment class from pixiedust.utils.environment import Environment Environment.pixiedustHome

/cc @glynnbird @bradnoble

glynnbird commented 7 years ago

Thanks David. That should be an easy fix.

glynnbird commented 7 years ago

Hi @DTAIEB I've made changes to fix the home directory when I create an npm/node subprocess to Environment.pixiedustHome. But it works just as before.

After some investigation, I've found out it's because the pixiedustHome directory doesn't have a node_modules directory so npm goes up the directory tree looking for one. It finds one in my home directory so modules get installed there.

It works as expected if the pixiedustHome directory contains a node_modules directory, so I modded the code to create the directory in pixiedust_node.

glynnbird commented 7 years ago

see https://github.com/ibm-watson-data-lab/pixiedust_node/pull/6