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. App Packaging & Development
  3. How can I use npm install after deploying an app?

How can I use npm install after deploying an app?

Scheduled Pinned Locked Moved App Packaging & Development
6 Posts 5 Posters 1.3k Views 5 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.
  • M Offline
    M Offline
    msbt
    App Dev
    wrote on last edited by
    #1

    I'm working on strapi and ran into an issue when installing plugins from the marketplace. This is running on node and plugins also run node commands. The problem: node_modules is in a read only location /app/pkg/app/node_modules, so the installation fails for obvious reasons.

    I couldn't find an app which does that, any pointers on how to overcome that? (other than moving everything to /app/data)

    mehdiM murgeroM 2 Replies Last reply
    0
    • M msbt

      I'm working on strapi and ran into an issue when installing plugins from the marketplace. This is running on node and plugins also run node commands. The problem: node_modules is in a read only location /app/pkg/app/node_modules, so the installation fails for obvious reasons.

      I couldn't find an app which does that, any pointers on how to overcome that? (other than moving everything to /app/data)

      mehdiM Offline
      mehdiM Offline
      mehdi
      App Dev
      wrote on last edited by
      #2

      @msbt There is no way to overcome that. It's by design. The app's code cannot be changed after build. The only work-around, like you said, would be to move to /app/data. Not necessarily "everything". You only have to symlink to /app/data the few paths which should still be writable after install

      1 Reply Last reply
      0
      • M Offline
        M Offline
        msbt
        App Dev
        wrote on last edited by
        #3

        Thanks @mehdi, was afraid that was the case. I guess it's easier to just install the few available plugins and go from there 😄

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

          Yes that is an unfortunate situation, but if possible either first package without custom plugin support or maybe there is a way to have a secondary folder for plugins to be used.

          Generally for the app itself, if that is going to be installed during startup with npm/yarn, this is not really acceptable since the app itself then may or may not differ from instance to instance, depending on how strictly the project has locked dependency versions or worse npm might fail intermittedly.

          1 Reply Last reply
          0
          • M msbt

            I'm working on strapi and ran into an issue when installing plugins from the marketplace. This is running on node and plugins also run node commands. The problem: node_modules is in a read only location /app/pkg/app/node_modules, so the installation fails for obvious reasons.

            I couldn't find an app which does that, any pointers on how to overcome that? (other than moving everything to /app/data)

            murgeroM Offline
            murgeroM Offline
            murgero
            App Dev
            wrote on last edited by murgero
            #5

            @msbt

            As @mehdi explained, symlinking is probably your best bet. If you know the directory where the node plugins/packages will go, symlink that dir pre-build:

            cd /app/data
            mkdir node_modules
            ln -s /app/data/node_modules /app/code/node_modules
            

            Please take note, I am not using trailing "/" here as that has been known to cause weird issues in the past for me. The above will create a symlink in /app/code that is read-write so npm install should work (you will get cache errors since /root is not writable (or where ever npm detects it's home dir to be) but cache is not needed for npm.

            This should only be done once though either during the build (if module license allows) or during the first startup. Otherwise as @nebulon explains - instance to instance code may break (like if a module was updated in a later version of the app.)

            --
            https://urgero.org
            ~ Professional Nerd. Freelance Programmer. ~

            1 Reply Last reply
            0
            • girishG Offline
              girishG Offline
              girish
              Staff
              wrote on last edited by
              #6

              @msbt I faced a similar issue with node-red. While I haven't tried it yet, I think what we want is to set NODE_PATH. See https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders . I guess we set NODE_PATH=/app/data/custom-modules or something ?

              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