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


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. N8N
  3. Using Jsonata

Using Jsonata

Scheduled Pinned Locked Moved N8N
9 Posts 3 Posters 1.6k Views 2 Watching
  • 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.
  • jeauJ jeau

    @girish great thank's, it works 👍

    S Offline
    S Offline
    samarvir
    wrote on last edited by samarvir
    #1

    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

    girishG 1 Reply Last reply
    0
    • S 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

      girishG Offline
      girishG Offline
      girish
      Staff
      wrote on last edited by
      #2

      @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
      0
      • girishG Offline
        girishG Offline
        girish
        Staff
        wrote on last edited by
        #3

        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.

        robiR 1 Reply Last reply
        0
        • girishG girish

          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.

          robiR Offline
          robiR Offline
          robi
          wrote on last edited by
          #4

          @girish why not link it over?

          Conscious tech

          girishG 1 Reply Last reply
          0
          • robiR robi

            @girish why not link it over?

            girishG Offline
            girishG Offline
            girish
            Staff
            wrote on last edited by
            #5

            @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.

            robiR 1 Reply Last reply
            0
            • girishG girish

              @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.

              robiR Offline
              robiR Offline
              robi
              wrote on last edited by
              #6

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

              like all of node_modules/

              Conscious tech

              girishG 1 Reply Last reply
              0
              • robiR robi

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

                like all of node_modules/

                girishG Offline
                girishG Offline
                girish
                Staff
                wrote on last edited by
                #7

                @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.

                robiR 1 Reply Last reply
                0
                • girishG girish

                  @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.

                  robiR Offline
                  robiR Offline
                  robi
                  wrote on last edited by robi
                  #8

                  @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/

                  Conscious tech

                  girishG 1 Reply Last reply
                  0
                  • robiR 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/

                    girishG Offline
                    girishG Offline
                    girish
                    Staff
                    wrote on last edited by
                    #9

                    @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
                    1
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Bookmarks
                    • Search