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

    Solved LAMP Laravel and npm

    LAMP
    2
    7
    368
    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.
    • D
      DeiWee last edited by

      Hello,

      I have LAMP and Laravel. By documentation npm install should work: https://docs.cloudron.io/apps/lamp/ but for www-data user I get command not found.

      If I check npm -v with root I get version, but I can't run npm install in /app/data/public.

      p.s. would be great to update this guide: https://docs.cloudron.io/guides/lamp-laravel/

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

        I think the problem is, that the www-data user has not setup the nodejs environment here. Since installing modules is likely an admin task here, I assume it would be fine to use root here and if needed change the permissions of the files later, but mostly those should not be written to or changed anyways.

        As far as I can tell, running npm as root within the /app/data/ directory will result in an npm cache failure. This can be mitigated by specifying a HOME directory, so you should be able to run npm fine as root using the following:

        HOME=/app/data/ npm install
        

        Regarding the docs, I will see how to fixup https://docs.cloudron.io/apps/lamp/#running-composer-npm-bundler

        D 1 Reply Last reply Reply Quote 1
        • D
          DeiWee @nebulon last edited by

          @nebulon Thanks, this worked!

          Note that you have to be in /app/data/public/ catalog with root.

          In this guide https://docs.cloudron.io/guides/lamp-laravel/ would be great to include schedule:run cron too.

          nebulon 1 Reply Last reply Reply Quote 0
          • nebulon
            nebulon Staff @DeiWee last edited by

            @deiwee good idea, I've added the schedule:run instructions to the docs now.

            D 1 Reply Last reply Reply Quote 0
            • D
              DeiWee @nebulon last edited by

              @nebulon Hello, I added schedule:run command to crontab file:

              * * * * * cd /app/data/public/ && sudo -u www-data /usr/bin/php /app/data/public/artisan schedule:run
              

              restarted app but it still not working 😞

              If I run schedule commands manually, it works. Any suggestions?

              D 1 Reply Last reply Reply Quote 0
              • D
                DeiWee @DeiWee last edited by

                @deiwee This combination worked for me:

                * * * * * /usr/bin/php /app/data/public/artisan schedule:run
                

                Regards.

                nebulon 1 Reply Last reply Reply Quote 0
                • nebulon
                  nebulon Staff @DeiWee last edited by

                  @deiwee I guess you would want to run it as www-data user though to not mess with file permissions. Did you get any error messages in the log? Of course after app restart it will always take at most a minute to kick the cron according to schedule.

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