4

After Installing and setup the Magento 2.3 how to run PWA in local ?

4

I have installed PWA in Magento2.3 in Ubuntu OS

Prerequisites

NodeJS >=10.14.1 LTS

Node Package Manager (NPM)

Step 1 Setup Fresh Magento 2.3

Step 2 Clone the PWA Studio repository into your development environment.

Step 3 Install PWA Studio dependencies

npm install

Step 4 Specify the Magento backend server

Under the packages/venia-concept directory, copy .env.dist into a new .env file:

Example command:

cp packages/venia-concept/.env.dist packages/venia-concept/.env

NOTE: In .env file do not change anything

Step 5 Add Venia Sample data

Create packages/venia-concept/deployVeniaSampleData.sh and copy paste below code

#!/usr/bin/env bash
    add_composer_repository () {
    name=$1
    type=$2
    url=$3
    echo "adding composer repository ${url}"
    ${composer} config ${composerParams} repositories.${name} ${type} ${url}
}

add_venia_sample_data_repository () {
    name=$1
    add_composer_repository ${name} github "${githubBaseUrl}/${name}.git"
}

execute_install () {
  composer='/usr/bin/env composer'
  composerParams='--no-interaction --ansi'
  moduleVendor='magento'
  moduleList=(
      module-catalog-sample-data-venia
      module-configurable-sample-data-venia
      module-customer-sample-data-venia
      module-sales-sample-data-venia
      module-tax-sample-data-venia
      sample-data-media-venia
  )
  githubBaseUrl='git@github.com:PMET-public'

  cd $install_path

  for moduleName in "${moduleList[@]}"
  do
     add_venia_sample_data_repository ${moduleName}
  done

  ${composer} require ${composerParams} $(printf "${moduleVendor}/%s:dev-master@dev " "${moduleList[@]}")
}


skip_interactive=0
install_path=./

while test $# -gt 0; do
  case "$1" in
    --help)
              echo "Magento 2 Venia Sample data script install."
              echo "if no options are passed, it will start interactive mode and ask for your Magento absolute path"
              echo ""
              echo "Usage:"
              echo "  deployVeniaSampleData.sh [options]"
              echo "Options:"
              echo "  --help    Displays this!"
              echo "  --yes     Skip interactive mode and installs data"
              echo "  --path    your Magento 2 absolute path, otherwise will install in current directory."
              echo ""

              exit 0
              ;;
--yes)        skip_interactive=1
              shift
              ;;
--path*)      if test $# -gt 0; then
                install_path=`echo $1 | sed -e 's/^[^=]*=//g'`
              fi
              shift
              ;;
*)            break
              ;;
  esac

done


if [ "$skip_interactive" == 1 ]; then
  echo "Skipping interactive mode.."
  echo "Install path ${install_path}"
  execute_install
else
  echo "Please specify absolute path to your Magento 2 instance"
  read -p 'Magento root folder: ' install_path

  echo "Sample data will be installed there."
  echo ""
  read -p "Are you sure you want to continue? [y/n]" yn

  case $yn in
    y )
      execute_install
      ;;
    n )
      echo "Sample Data instalation failed."
      exit 0
      ;;
    * )
      echo "Exiting..."
      exit 1
      ;;
  esac

fi

Step 6 Start the server

Before you run the server, generate build artifacts for Venia using the following command in the project root directory:

npm run build

Run the server

Use any of the following commands from the project root directory to start the server:

npm run watch:venia
| improve this answer | |
  • Hi @yann-martel If this answer helps you please accept. – hweb87 Jan 10 '19 at 6:22
  • I'm getting error : lerna ERR! npm run build -s exited 1 in '@magento/pwa-buildpack' lerna ERR! npm run build -s stdout: – Kaushal Suthar Jan 10 '19 at 7:21
  • @KaushalSuthar checkout package-lock.json, package.json then run npm install, then run npm run build, then run npm run watch:venia – hweb87 Jan 10 '19 at 9:42
  • @hweb87 can you please tell me in windows also – User0434 Aug 7 '19 at 10:14
  • 1
    @hweb87 i got the answer from magento.stackexchange.com/a/299021/27183 .... yarn create @magento/pwa inside the magento pwa studio will create a new project to work for. – santhoshnsscoe Jan 8 at 12:47
1

First of all install Node js latest version using following command

- curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
- sudo apt-get install -y nodejs
- sudo apt install npm

Now go to Magento Root directory :

- cd var/www/html/pwa-magento/

Download PWA clone directory and install npm into this directory using following commands

- git clone https://github.com/magento-research/pwa-studio.git
- cd pwa-studio/
- sudo npm install
- cp packages/venia-concept/.env.dist packages/venia-concept/.env
- sudo npm run build

==========================================

if npx not found error PWA magento 2.3

- sudo npm i -g npx

if error found like this : Cannot find module 'envalid' then run following command

- sudo npm install i envalid
- sudo npm install envalid

if error like this then run following command : lerna ERR! npm run build -s exited 1 in '@magento/venia-concept'

- sudo npm restart
- sudo npm run stage:venia
- sudo npm cache clean -f
- sudo npm install -g n
- sudo n stable / sudo n latest (depends on version)

===========================================

- sudo npm i @magento/pwa-buildpack
- sudo npm i @magento/upward-js
- sudo npm i @magento/venia-concept

- sudo npm run build
- sudo npm run watch:venia
- sudo npm run watch:all
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.