tslab icon indicating copy to clipboard operation
tslab copied to clipboard

tslab cannot find globally-installed modules even when NODE_PATH is set

Open athewsey opened this issue 4 years ago • 1 comments

Hi & thanks for your work putting tslab together!

(I believe this is separate from #40, which is talking about the built-in fs module that works fine for me).

I'm trying to use tslab in a containerised environment with some globally-installed packages e.g.:

RUN npm install -g \
    @tensorflow/[email protected] \
    @tensorflow/[email protected] \
    @tensorflow/[email protected] \

The packages get installed in the /usr/lib/node_modules folder.

I understand that NodeJS require can't find globally-installed packages by default, but setting the NODE_PATH environment variable can fix it. However, not with tslab it seems...

Is there some other way to enable this?

Expected behavior:

tslab/jslab kernels should be able to see global packages - either always as a design decision, or else iff the NODE_PATH environment variable is set.

Observed behavior:

Setting the environment variable in my container, I can see:

  • process.env.NODE_PATH is set, inside the jslab kernel, and
  • Standard node in a terminal can require the packages correctly if referenced in a script file, but
  • I cannot e.g. require("@tensorflow/tfjs") in the kernel - getting error like Cannot find module '@tensorflow/tfjs' or its corresponding type declarations.

Setup:

  • tslab version: 1.0.15
  • Kernel: JavaScript (jslab)
  • Platform: Linux (Ubuntu 18.04)

athewsey avatar Apr 26 '21 10:04 athewsey

^ My current workaround to this is to just install the packages higher up in the filesystem, instead of using -g flag - which enables the resolver to find them.

athewsey avatar Apr 27 '21 16:04 athewsey