0

I'm trying to import an external javascript module (e.g., log4js). However, I have issues with loading in javascript packages specified in my package.json into my Jupyter extension. My project setup looks something like this:

├── logger/
│   └── __init__.py
│   └── static/
│       └── main.js
├── node_modules/
│   ├── log4js/
│   └── ...
└── pacakge.json
│   
└── setup.py

This is what my main.js looks like:

define([
    'base/js/namespace',
    'jquery',
    'log4js'
  ], function (Jupyter,$,log4js) {
    "use strict";
    function load_ipython_extension() {
      console.log("Loaded Logger")
      // var log4js = require("log4js");
      var logger = log4js.getLogger();
    }

    return {
      load_ipython_extension: load_ipython_extension
    };

 });

I am able to import the jquery variable into $ successfully, however, any other package that is installed inside node_module can not be loaded in and results in the same Error: Script error. Any idea on how to appropriately place the node_module packages into the scope of the Jupyter extension would be very helpful, thanks!

error message

ROBOTPWNS
  • 4,299
  • 6
  • 23
  • 36

1 Answers1

0

From the informations you gave here I can guess that you need to setup paths to libraries from node_modules. As you can see you have 404 errors in the browser which means that RequireJS is trying to load the modules but from wrong paths. You can read more about paths on official page: https://requirejs.org/docs/api.html#config-paths

Damian Dziaduch
  • 2,107
  • 1
  • 15
  • 16