PWA build fails

If this command fails:

yarn run build

The installed Node modules are probably outdated relative to your code (the Git HEAD pointer).

cd /path/to/project
rm -rf node_modules
yarn install
yarn run build

Browser doesn’t trust the certificate

For macOS, delete the devcert directory. PWA Buildpack will regenerate certificates and fix the issue.

cd ~/Library/Application\ Support/
rm -rf devcert

Reference: Magento PWA Docs — PWA Buildpack Troubleshooting

Build doesn’t trust the certificate

For local development only.

Add this to your package’s .env file, so Node won’t balk at a self-signed certificate.


Build forgets the project domain

When the self-signed certificate expires, the build can’t validate it so it abandons the custom origin and reverts to This allows the build to re-sign the certificate and use it again.

yarn run buildpack create-custom-origin packages/{yourPackage}

Detect build mode in React code

if (process.env.NODE_ENV === 'production') {
    // Something

if (process.env.NODE_ENV === 'development') {
    // Something