Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jabrij93's avatar

Github-action, error running npm run dev -TypeError: Cannot read properties of undefined (reading 'replace')

I am trying to connect my github laravel repository to cpanel so I can push it to my hosted web app everytime there's changes. So I follow the guide in the comments on this link, https://stackoverflow.com/questions/70996923/is-that-possible-to-deploy-laravel-web-application-to-shared-hosting-using-githu .As I filled all the info required and ran it, the following are the errors that I get. I tried to solve the error and refer to guide on this stackoverflow link in the comments but it is not working, https://stackoverflow.com/questions/70340751/github-action-npm-install-error-process-completed-with-exit-code-1 . Please help.

  npm run production
  shell: /usr/bin/bash -e {0}
  env:
    COMPOSER_PROCESS_TIMEOUT: 0
    COMPOSER_NO_INTERACTION: 1
    COMPOSER_NO_AUDIT: 1
  npm ERR! Missing script: "production"
  npm ERR! 
  npm ERR! To see a list of scripts, run:
  npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2022-12-06T11_58_08_283Z-debug-0.log
Error: Process completed with exit code 1.```

my package.json

{
    "private": true,
    "scripts": {
        "preinstall": "npx npm-force-resolutions",
        "dev": "vite",
        "build": "vite build"
    },
    "devDependencies": {
        "@tailwindcss/forms": "^0.5.2",
        "@tailwindcss/typography": "^0.5.0",
        "alpinejs": "^3.0.6",
        "autoprefixer": "^10.4.7",
        "axios": "^0.25",
        "laravel-vite-plugin": "^0.5.0",
        "lodash": "^4.17.19",
        "postcss": "^8.4.14",
        "tailwindcss": "^3.1.0",
        "vite": "^3.0.0"
    },
    "dependencies": {
        "chart.js": "^3.8.0",
        "chartjs-adapter-moment": "^1.0.0",
        "flatpickr": "^4.6.13",
        "moment": "^2.29.4"
    },
    "resolutions": {
      "node-sass": "https://registry.npmjs.org/dart-sass/-/dart-sass- 
       1.25.0.tgz"
    },
}

my main.yaml file:

on: 
  push:
    branches:
      - main
name: 🚀 Deploy website on push
jobs:
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v2

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: 8.1.11

    - name: Cache Composer packages
      id: composer-cache
      uses: actions/cache@v2
      with:
        path: vendor
        key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
        restore-keys: |
          ${{ runner.os }}-php-

    - name: Save state
      run: echo "{name}={value}" >> $GITHUB_STATE

    - name: Set output
      run: echo "{name}={value}" >> $GITHUB_OUTPUT

    - name: Install dependencies
      run: composer install --prefer-dist --no-progress

    - name: install npm 
      run:  npm install

    - name: run npm production
      run:  npm run production       
    
    - name: 📂 Sync files
      uses: SamKirkland/[email protected]
      with:
        server: ftp.sabahloka.com
        username: ${{ secrets.ftp_username }}
        password: ${{ secrets.ftp_password }}
        server-dir: /home/sabahlok/hackathon2.dfa-learning.sabahloka.com/
0 likes
4 replies
ottoszika's avatar

You have no production script defined in the scripts entry of package.json, but you have a build one, so you can change the npm run production command in your step with npm run build.

jabrij93's avatar

@ottoszika hey thanks for pointing that out. i used npm run build and now it is showing

   Error: getaddrinfo EAI_AGAIN ftp.sabahloka.com
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
  errno: -3001,
  code: 'EAI_AGAIN',
  syscall: 'getaddrinfo',
  hostname: 'ftp.sabahloka.com'
}
Error: Error: getaddrinfo EAI_AGAIN ftp.sabahloka.com (control socket)
ottoszika's avatar

@jabrij93 Is the hostname ftp.sabahloka.com valid? If this is a new domain, ensure you set up the nameservers correctly and that there is an A record for that particular subdomain that points to the FTP server.

jabrij93's avatar

@ottoszika its very strange..i added a port and now it is working..thanks man ! really appreciate the help

Please or to participate in this conversation.