Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Using Jsonata

    N8N
    3
    9
    202
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      samarvir @jeau last edited by samarvir

      Hey @girish handlebars and uuid packages are working as expected but not for
      Jsonata

      Screenshot 2021-11-02 at 09.36.33.png

      Screenshot 2021-11-02 at 09.37.09.png

      Please let me know if I am missing something or any work arounds .

      Thanks. this is awesome.Screenshot 2021-11-02 at 09.56.03.png

      girish 1 Reply Last reply Reply Quote 0
      • girish
        girish Staff @samarvir last edited by

        @samarvir I can reproduce the problem. It turns out NODE_PATH never worked. handlebars only seemed to work because handlebars was already part of n8n!

        1 Reply Last reply Reply Quote 0
        • girish
          girish Staff last edited by

          OK, on investigation what I found is:

          • n8n uses vm2 to run code.
          • vm2 in turn uses node's built-in vm module.
          • However, vm2 does not use NODE_PATH - https://github.com/patriksimek/vm2/blob/master/lib/sandbox.js#L250 . So, the solution that I had earlier is wrong. It just happened to work for handlebars and some other random modules I tried.

          All this means that we can only use the modules in /app/code/node_modules.

          Since jsonata seems generally useful, I have included it in the package itself. Let me know if you need other node modules and I can add them.

          robi 1 Reply Last reply Reply Quote 0
          • robi
            robi @girish last edited by

            @girish why not link it over?

            Life of Gratitude.
            Life of Advanced Technology

            girish 1 Reply Last reply Reply Quote 0
            • girish
              girish Staff @robi last edited by

              @robi each module brings it's own set of dependencies. So, we have lots of folder of symlink taking into account somehow that they might conflict with upstream's node dependencies. npm usually sorts this all out keeping directory structure flat and gives each module it's own copy when modules conflict, very hard to just symlink.

              robi 1 Reply Last reply Reply Quote 0
              • robi
                robi @girish last edited by

                @girish there has to be a higher pivot point where individual symlinking isn't necessary, no?

                like all of node_modules/

                Life of Gratitude.
                Life of Advanced Technology

                girish 1 Reply Last reply Reply Quote 0
                • girish
                  girish Staff @robi last edited by

                  @robi usually NODE_PATH works. It's an additional path where system wide node_modules can be found. But it doesn't work with the vm module.

                  Symlinking all of node_modules essentially means copying over all the code to a writable location and installing user modules on application startup. We might as well run the app from /app/data at this point. Generally, we don't do this in Cloudron unless there is no other way and we cannot live without it.

                  robi 1 Reply Last reply Reply Quote 0
                  • robi
                    robi @girish last edited by robi

                    @girish I see.

                    looking at vm2 there are ways to specify modules by relative paths in the script.
                    https://www.npmjs.com/package/vm2/v/3.6.4?activeTab=readme

                    Ctrl-f on "Loading modules by relative path"

                    same here:
                    https://github.com/patriksimek/vm2

                    Here it mentions using NODE_EXECUTABLE
                    https://pypi.org/project/node-vm2/

                    Life of Gratitude.
                    Life of Advanced Technology

                    girish 1 Reply Last reply Reply Quote 0
                    • girish
                      girish Staff @robi last edited by

                      @robi correct, vm2 can be made to load them but n8n does not configure it that way. I guess this has to be reported upstream to n8n to support loading modules outside node_modules.

                      1 Reply Last reply Reply Quote 1
                      • First post
                        Last post
                      Powered by NodeBB