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. LAMP
  3. Using YARN

Using YARN

Scheduled Pinned Locked Moved Solved LAMP
16 Posts 3 Posters 3.9k 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.
  • FoksVHoxF FoksVHox

    Hello!

    I'd like to hear how I'd be able to use the YARN package manager instead of NPM, in the LAMP app?

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

    @FoksVHox yarn is already there. Does the below work in a Web Terminal ?

    root@d8e7cdf87e6b:/# yarn --version
    1.22.17
    
    FoksVHoxF 1 Reply Last reply
    0
    • girishG girish

      @FoksVHox yarn is already there. Does the below work in a Web Terminal ?

      root@d8e7cdf87e6b:/# yarn --version
      1.22.17
      
      FoksVHoxF Offline
      FoksVHoxF Offline
      FoksVHox
      wrote on last edited by
      #3

      @girish said in Using YARN:

      yarn --version

      Sorry for the late reply, it indeed does, however, when using custom commands, that are specified within your package.json file, it doesn't work.

      This is my package.json file:

      {
          "private": true,
          "scripts": {
              "dev": "vite",
              "build": "vite build"
          },
          "devDependencies": {
              "@babel/core": "^7.18.13",
              "@babel/plugin-proposal-object-rest-spread": "^7.18.6",
              "@babel/plugin-syntax-dynamic-import": "^7.8.3",
              "@babel/plugin-transform-runtime": "^7.18.10",
              "@babel/preset-env": "^7.18.10",
              "@tailwindcss/forms": "^0.5.2",
              "alpinejs": "^3.10.3",
              "apexcharts": "^3.35.5",
              "autoprefixer": "^10.4.8",
              "axios": "^0.27",
              "clockwork-browser": "^1.1.1",
              "cross-env": "^7.0.3",
              "laravel-echo": "^1.14.0",
              "laravel-vite-plugin": "^0.5.0",
              "lodash": "^4.17.21",
              "mix-tailwindcss": "^1.3.0",
              "object-path": ">=0.11.8",
              "postcss": "^8.4.16",
              "pusher-js": "^7.4.0",
              "resolve-url-loader": "^5.0.0",
              "sass": "^1.54.7",
              "sass-loader": "^13.0.2",
              "tailwindcss": "^3.1.8",
              "vite": "^3.0.2",
              "vue-template-compiler": "^2.7.10",
              "webpack": "^5.74.0",
              "webpack-cli": "^4.10.0"
          },
          "dependencies": {
              "@alpinejs/mask": "^3.10.3",
              "@tailwindcss/aspect-ratio": "^0.4.0",
              "@tailwindcss/line-clamp": "^0.4.0"
          }
      }
      

      When I run yarn build I get the following error.

      root@de780a18-b997-4803-a5b2-f07549cad279:/app/data/lectero# yarn build
      yarn run v1.22.17
      warning Skipping preferred cache folder "/usr/local/share/.cache/yarn" because it is not writable.
      warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-0".
      $ vite build
      warning Cannot find a suitable global folder. Tried these: "/usr/local, /usr/local/share/.yarn"
      /bin/sh: 1: vite: not found
      error Command failed with exit code 127.
      info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
      

      And I also think it has something to do with the version of Yarn not being version 2

      nebulonN 1 Reply Last reply
      0
      • FoksVHoxF FoksVHox

        @girish said in Using YARN:

        yarn --version

        Sorry for the late reply, it indeed does, however, when using custom commands, that are specified within your package.json file, it doesn't work.

        This is my package.json file:

        {
            "private": true,
            "scripts": {
                "dev": "vite",
                "build": "vite build"
            },
            "devDependencies": {
                "@babel/core": "^7.18.13",
                "@babel/plugin-proposal-object-rest-spread": "^7.18.6",
                "@babel/plugin-syntax-dynamic-import": "^7.8.3",
                "@babel/plugin-transform-runtime": "^7.18.10",
                "@babel/preset-env": "^7.18.10",
                "@tailwindcss/forms": "^0.5.2",
                "alpinejs": "^3.10.3",
                "apexcharts": "^3.35.5",
                "autoprefixer": "^10.4.8",
                "axios": "^0.27",
                "clockwork-browser": "^1.1.1",
                "cross-env": "^7.0.3",
                "laravel-echo": "^1.14.0",
                "laravel-vite-plugin": "^0.5.0",
                "lodash": "^4.17.21",
                "mix-tailwindcss": "^1.3.0",
                "object-path": ">=0.11.8",
                "postcss": "^8.4.16",
                "pusher-js": "^7.4.0",
                "resolve-url-loader": "^5.0.0",
                "sass": "^1.54.7",
                "sass-loader": "^13.0.2",
                "tailwindcss": "^3.1.8",
                "vite": "^3.0.2",
                "vue-template-compiler": "^2.7.10",
                "webpack": "^5.74.0",
                "webpack-cli": "^4.10.0"
            },
            "dependencies": {
                "@alpinejs/mask": "^3.10.3",
                "@tailwindcss/aspect-ratio": "^0.4.0",
                "@tailwindcss/line-clamp": "^0.4.0"
            }
        }
        

        When I run yarn build I get the following error.

        root@de780a18-b997-4803-a5b2-f07549cad279:/app/data/lectero# yarn build
        yarn run v1.22.17
        warning Skipping preferred cache folder "/usr/local/share/.cache/yarn" because it is not writable.
        warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-0".
        $ vite build
        warning Cannot find a suitable global folder. Tried these: "/usr/local, /usr/local/share/.yarn"
        /bin/sh: 1: vite: not found
        error Command failed with exit code 127.
        info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
        

        And I also think it has something to do with the version of Yarn not being version 2

        nebulonN Offline
        nebulonN Offline
        nebulon
        Staff
        wrote on last edited by
        #4

        @FoksVHox have you run yarn install prior to running yarn build ?

        FoksVHoxF 1 Reply Last reply
        0
        • nebulonN nebulon

          @FoksVHox have you run yarn install prior to running yarn build ?

          FoksVHoxF Offline
          FoksVHoxF Offline
          FoksVHox
          wrote on last edited by
          #5

          @nebulon Yes. I can confirm this has something to do with the version of Yarn not being Yarn v2.

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

            Actually to take a step back, from your package.json it looks like there is nothing yarn specific, couldn't you just use npm there instead?

            FoksVHoxF 1 Reply Last reply
            0
            • nebulonN nebulon marked this topic as a question on
            • nebulonN nebulon

              Actually to take a step back, from your package.json it looks like there is nothing yarn specific, couldn't you just use npm there instead?

              FoksVHoxF Offline
              FoksVHoxF Offline
              FoksVHox
              wrote on last edited by
              #7

              @nebulon said in Using YARN:

              Actually to take a step back, from your package.json it looks like there is nothing yarn specific, couldn't you just use npm there instead?

              Well I could, however, npm is often way slower than yarn is.

              nebulonN 1 Reply Last reply
              0
              • FoksVHoxF FoksVHox

                @nebulon said in Using YARN:

                Actually to take a step back, from your package.json it looks like there is nothing yarn specific, couldn't you just use npm there instead?

                Well I could, however, npm is often way slower than yarn is.

                nebulonN Offline
                nebulonN Offline
                nebulon
                Staff
                wrote on last edited by
                #8

                @FoksVHox actually I have mixed experience there since some npm releases. But either way would a few seconds make much difference in your case compared to it working?

                FoksVHoxF 1 Reply Last reply
                0
                • nebulonN nebulon

                  @FoksVHox actually I have mixed experience there since some npm releases. But either way would a few seconds make much difference in your case compared to it working?

                  FoksVHoxF Offline
                  FoksVHoxF Offline
                  FoksVHox
                  wrote on last edited by
                  #9

                  @nebulon I've tried to use npm but it seems that it won't work either.

                  nebulonN 1 Reply Last reply
                  0
                  • FoksVHoxF FoksVHox

                    @nebulon I've tried to use npm but it seems that it won't work either.

                    nebulonN Offline
                    nebulonN Offline
                    nebulon
                    Staff
                    wrote on last edited by
                    #10

                    @FoksVHox is there any other error with npm?

                    FoksVHoxF 1 Reply Last reply
                    0
                    • nebulonN nebulon

                      @FoksVHox is there any other error with npm?

                      FoksVHoxF Offline
                      FoksVHoxF Offline
                      FoksVHox
                      wrote on last edited by
                      #11

                      @nebulon There is:

                      EACCES: permission denied, open '/app/data/lectero/public/build/assets/app.22fa980f.js'
                      error during build:
                      Error: EACCES: permission denied, open '/app/data/lectero/public/build/assets/app.22fa980f.js'
                      
                      nebulonN girishG 2 Replies Last reply
                      0
                      • FoksVHoxF FoksVHox

                        @nebulon There is:

                        EACCES: permission denied, open '/app/data/lectero/public/build/assets/app.22fa980f.js'
                        error during build:
                        Error: EACCES: permission denied, open '/app/data/lectero/public/build/assets/app.22fa980f.js'
                        
                        nebulonN Offline
                        nebulonN Offline
                        nebulon
                        Staff
                        wrote on last edited by
                        #12

                        @FoksVHox seems like a permission issue then. Make sure that the user, with whom you are running npm, has write access to those folders.

                        1 Reply Last reply
                        0
                        • FoksVHoxF FoksVHox

                          @nebulon There is:

                          EACCES: permission denied, open '/app/data/lectero/public/build/assets/app.22fa980f.js'
                          error during build:
                          Error: EACCES: permission denied, open '/app/data/lectero/public/build/assets/app.22fa980f.js'
                          
                          girishG Offline
                          girishG Offline
                          girish
                          Staff
                          wrote on last edited by
                          #13

                          @FoksVHox If you are running as www-data user, you have to chown -R www-data:www-data /app/data/public

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

                            Was just investigating this a bit. What I found is that yarn wants to write as root user into /usr/local/share/.yarnrc. This is reported upstream as bug https://github.com/yarnpkg/yarn/issues/4628

                            Workaround (you can put this in /app/data/.bashrc if you like):

                            export YARN_DISABLE_SELF_UPDATE_CHECK="true"
                            

                            After this, I am able to install easily:

                            root@38e05e7c-8aee-426e-85ef-a577d080c39c:/app/data/public# yarn add safetydance
                            yarn add v1.22.17
                            warning package.json: No license field
                            warning Skipping preferred cache folder "/usr/local/share/.cache/yarn" because it is not writable.
                            warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-0".
                            warning No license field
                            [1/4] Resolving packages...
                            [2/4] Fetching packages...
                            [3/4] Linking dependencies...
                            [4/4] Building fresh packages...
                            
                            success Saved lockfile.
                            warning No license field
                            success Saved 1 new dependency.
                            info Direct dependencies
                            └─ safetydance@2.2.0
                            info All dependencies
                            └─ safetydance@2.2.0
                            Done in 1.15s.
                            root@38e05e7c-8aee-426e-85ef-a577d080c39c:/app/data/public#
                            
                            FoksVHoxF 1 Reply Last reply
                            1
                            • girishG girish

                              Was just investigating this a bit. What I found is that yarn wants to write as root user into /usr/local/share/.yarnrc. This is reported upstream as bug https://github.com/yarnpkg/yarn/issues/4628

                              Workaround (you can put this in /app/data/.bashrc if you like):

                              export YARN_DISABLE_SELF_UPDATE_CHECK="true"
                              

                              After this, I am able to install easily:

                              root@38e05e7c-8aee-426e-85ef-a577d080c39c:/app/data/public# yarn add safetydance
                              yarn add v1.22.17
                              warning package.json: No license field
                              warning Skipping preferred cache folder "/usr/local/share/.cache/yarn" because it is not writable.
                              warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-0".
                              warning No license field
                              [1/4] Resolving packages...
                              [2/4] Fetching packages...
                              [3/4] Linking dependencies...
                              [4/4] Building fresh packages...
                              
                              success Saved lockfile.
                              warning No license field
                              success Saved 1 new dependency.
                              info Direct dependencies
                              └─ safetydance@2.2.0
                              info All dependencies
                              └─ safetydance@2.2.0
                              Done in 1.15s.
                              root@38e05e7c-8aee-426e-85ef-a577d080c39c:/app/data/public#
                              
                              FoksVHoxF Offline
                              FoksVHoxF Offline
                              FoksVHox
                              wrote on last edited by
                              #15

                              @girish Will you update the thread once the issue has been resolved?

                              girishG 1 Reply Last reply
                              0
                              • FoksVHoxF FoksVHox

                                @girish Will you update the thread once the issue has been resolved?

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

                                @FoksVHox Will do. I am subscribed to that issue, but it's open for 5 years now, so I have no hope 🙂

                                1 Reply Last reply
                                0
                                • girishG girish has marked this topic as solved 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