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. How to install NPM packages that n8n App can use?

How to install NPM packages that n8n App can use?

Scheduled Pinned Locked Moved Solved N8N
9 Posts 3 Posters 5.7k Views 3 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.
  • A Offline
    A Offline
    AmbroiseUnly
    wrote on last edited by
    #1

    Following a discussion I had on n8n forum, I wonder what are the steps to install a new NPM package so that n8n can access it.

    It seems to need to be installed globally (-g) but a documented process about how to do that would be good.
    Typically, where do I need to do it? Does it work if I do that on the server instance itself? or do I need to do it in some Docker instance for n8n?

    Having this being documented in https://www.cloudron.io/store/io.n8n.cloudronapp.html would be a great addition.

    1 Reply Last reply
    0
    • nebulonN Offline
      nebulonN Offline
      nebulon
      Staff
      wrote on last edited by
      #2

      Have you seen https://docs.cloudron.io/apps/n8n/ already?

      1 Reply Last reply
      0
      • nebulonN nebulon moved this topic from Support on
      • nebulonN nebulon marked this topic as a question on
      • A Offline
        A Offline
        AmbroiseUnly
        wrote on last edited by
        #3

        @nebulon Yes, I had read those. I'm confused about whether those NPM packages need to be installed (in addition to changing the config file), and if so, how. I believe the documentation might be missing a key step, or maybe the installation of those packages is being done under the wheel, but I very much doubt so.

        Here is a video that might explain better my issue:
        https://www.loom.com/share/801e7f5745974be4b9676478053f7ff4

        1 Reply Last reply
        0
        • nebulonN Offline
          nebulonN Offline
          nebulon
          Staff
          wrote on last edited by
          #4

          We will mention it in the docs, but yes on app restart the specified node modules (from EXTRA_NODE_MODULES) will get installed automatically: https://git.cloudron.io/cloudron/n8n-app/-/blob/master/start.sh?ref_type=heads#L51

          1 Reply Last reply
          1
          • A Offline
            A Offline
            AmbroiseUnly
            wrote on last edited by
            #5

            Okay, hence the best practice of specifying the module's version, otherwise the major version might change upon any app restart.

            1 Reply Last reply
            0
            • nebulonN nebulon has marked this topic as solved on
            • A Offline
              A Offline
              AmbroiseUnly
              wrote on last edited by
              #6

              @nebulon How does one checks that a specified node module is installed?

              I'm asking because despite having added cloudinary and restarted the n8n app, I'm still facing the same issue

              # https://docs.n8n.io/reference/environment-variables.html
              export EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=true
              export EXECUTIONS_DATA_SAVE_ON_ERROR=all
              export EXECUTIONS_DATA_SAVE_ON_SUCCESS=all
              export N8N_LOG_LEVEL=info
              
              export EXECUTIONS_DATA_PRUNE=true
              export EXECUTIONS_DATA_MAX_AGE=672
              
              # Allow node modules to be used in code node - https://docs.n8n.io/hosting/configuration/#use-built-in-and-external-modules-in-the-code-node
              # Allows usage of all builtin modules
              export NODE_FUNCTION_ALLOW_BUILTIN=*
              
              # Allow usage of external npm modules
              # Those modules are auto-installed by Cloudron upon app restart, see https://forum.cloudron.io/topic/11946/how-to-install-npm-packages-that-n8n-app-can-use/4?_=1719382777426
              export NODE_FUNCTION_ALLOW_EXTERNAL=cloudinary@2.2.0
              

              Getting:

              VMError: Cannot find module 'cloudinary' at LegacyResolver.resolveFull (/app/code/node_modules/@n8n/vm2/lib/resolver.js:126:9) at LegacyResolver.resolveFull (/app/code/node_modules/@n8n/vm2/lib/resolver.js:316:16) at LegacyResolver.resolveFull (/app/code/node_modules/@n8n/vm2/lib/resolver-compat.js:147:17) at LegacyResolver.resolve (/app/code/node_modules/@n8n/vm2/lib/resolver.js:121:15) at resolve (/app/code/node_modules/@n8n/vm2/lib/nodevm.js:317:21) at VM2 Wrapper.apply (/app/code/node_modules/@n8n/vm2/lib/bridge.js:485:11) at requireImpl (/app/code/node_modules/@n8n/vm2/lib/setup-node-sandbox.js:90:19) at require (/app/code/node_modules/@n8n/vm2/lib/setup-node-sandbox.js:171:10) at /app/code/node_modules/n8n-nodes-base/dist/nodes/Code:1:117 at /app/code/node_modules/n8n-nodes-base/dist/nodes/Code:43:2
              
              

              image.png

              1 Reply Last reply
              0
              • A AmbroiseUnly referenced this topic on
              • girishG Offline
                girishG Offline
                girish
                Staff
                wrote on last edited by
                #7

                You have to install the modules via the EXTRA_NODE_MODULES variable - https://docs.cloudron.io/apps/n8n/#custom-node-modules . Then, those are whitelisted using NODE_FUNCTION_ALLOW_EXTERNAL

                1 Reply Last reply
                1
                • A Offline
                  A Offline
                  AmbroiseUnly
                  wrote on last edited by
                  #8

                  Ahhh, that's what I had missed! Thanks

                  The env.sh file default should definitely mention all of this more in details

                  And I'd suggest to enable built in (fs, etc.) by default, that's clearly not a security issue, and most of the people would want to use those. But that's a different topic.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    AmbroiseUnly
                    wrote on last edited by AmbroiseUnly
                    #9

                    Just for the sake of documenting, here is what I ended up with, in my .env.sh file:

                    # ------------- NODE MODULES ---------------------
                    
                    # Allow node modules to be used in code node - https://docs.n8n.io/hosting/configuration/#use-built-in-and-external-modules-in-the-code-node
                    # Allows usage of all builtin modules
                    export NODE_FUNCTION_ALLOW_BUILTIN=*
                    
                    # FYI This is a SPACE separated list
                    export EXTRA_NODE_MODULES="cloudinary@2.2.0 node-fetch@3.1.1"
                    
                    # Allow usage of external npm modules
                    # Those modules are auto-installed by Cloudron upon app restart, see https://forum.cloudron.io/topic/11946/how-to-install-npm-packages-that-n8n-app-can-use/4?_=1719382777426
                    # FYI This is a COMMA separated list
                    export NODE_FUNCTION_ALLOW_EXTERNAL=cloudinary,node-fetch
                    
                    1 Reply Last reply
                    1
                    • A AmbroiseUnly referenced this topic on
                    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