• @Coder2012 glad you got this sorted - kinda. When you require something in Espruino it just grabs that single file as you named it. In something like Node.js it'll look in node_modules, find the folder with that name, then look in package.json and then load the file that it references - so dragging something directly off NPM is super unlikely to work.

    Sadly the removal of NPM support in the IDE was because the vast, vast majority of modules on NPM are just too big to be usable. It was just super-confusing for everyone. It may end up getting re-enabled with some tree-shaking support that would hopefully be able to strip things back down a bit though.

    Crazily it looks like TweenLite is actually bigger than Tween. On Espruino you can pull in Tween as-is - you just require some simple wrapper functions:

    var TWEEN = require("https://cdnjs.cloudflare.com/aj­ax/libs/tween.js/17.2.0/Tween.min.js");
    process.hrtime = function() {
      var t = getTime();
      var s = 0|t;
      return [s, 0|((t-s)*1000000000)];
    function requestAnimationFrame(cb) {
    function animate(time) {
    var coords = { x: 0, y: 0 }; // Start at (0, 0)
    var tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
            .to({ x: 300, y: 200 }, 1000) // Move to (300, 200) in 1 second.
            .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
            .onUpdate(function() { // Called after tween.js updates 'coords'.
            .start(); // Start the tween immediately.

    @Robin I think this is basically unrelated to your problems. NPM doesn't interfere with the IDE or anything like that. As far as I can tell from the issues you posted to date, your problems were either with how you used the modules you defined, or your use of ES6 classes which while supported by Espruino aren't handled properly by the minifier the IDE uses yet.


Avatar for Gordon @Gordon started