Troubleshooting front-end pipeline failures in AEM as a Cloud Service

When converting a full-stack pipeline to a front-end (FE) only pipeline in AEM as a Cloud Service, build failures might occur due to platform-specific dependencies and strict linting requirements. Generating package-lock.json on Windows or macOS can cause incompatibilities with the Linux-based Cloud Manager. Additionally, FE pipelines enforce code-style checks not present in full-stack Maven builds.

Notes

  • When Cloud Manager runs a front-end pipeline it does not execute npm install first, it simply takes the package-lock.json that is in Git and runs npm audit --production --audit-level=critical. However a full-stack pipeline installs the Node/NPM versions we request through the frontend-maven-plugin, it runs npm install, hence we don’t see the issue in full stack pipeline.

Description description

Environment

  • Product: AEM as a Cloud Service – Sites
  • Pipeline: Front-end only (FE) pipeline via Cloud Manager
  • Node version: 14.19.1
  • npm version: 6.14.x
  • Operating system for local builds: Windows (local), Linux (Cloud Manager container)
  • Required permissions: Deployment Manager role in Cloud Manager

Issue/Symptoms

  • Pipeline fails during npm install with errors such as * fsevents not accessible from chokidar*
  • Errors related to missing or mismatched package-lock.json files
  • Local builds succeed on Windows or Mac, but fail in the Cloud Manager pipeline
  • Hundreds of ESLint/code-style errors cause FE-only pipeline failures, while full-stack pipelines do not enforce these checks by default

Resolution resolution

Try the following steps to resolve the issue:

  1. Ensure package-lock.json exists in the ui.frontend module and is committed to your repository.

  2. Regenerate package-lock.json and node_modules using a Linux environment (use Windows Subsystem for Linux or Docker). To reproduce and resolve platform-specific dependency issues for FE-only pipelines, use the following commands in a WSL terminal:  

    code language-none
    cd /path/to/your/project
    rm -rf package-lock.json node_modules
    npm install
    git add package-lock.json
    git commit -m "Regenerate package-lock.json on Linux"
    

     
    Or run in a Linux container:
     

    code language-none
    docker run --rm -v $(pwd):/app -w /app node:16-alpine \
      sh -c "rm -rf node_modules package-lock.json && npm install"
    

     

  3. Update outdated dependencies including Jest, Storybook, and Webpack.

  4. Use npm audit with production and critical audit level flags to identify remaining dependency issues. For example: npm audit --production --audit-level=critical

  5. Commit the regenerated package-lock.json file from the Linux environment to your repository.

  6. Push changes to the branch used by the FE-only pipeline.

  7. Rerun the FE-only pipeline in Cloud Manager.

  8. Address any ESLint/code-style errors reported during the build process; all lint errors must be resolved for successful deployment.

  9. If necessary for validation purposes only, temporarily remove linting from the build script in package.json. However, this is not recommended for production use.

  10. Verify that the build step completes successfully without dependency or linting errors.

  11. If the deployment succeeds but your site’s styles and scripts do not load, check Dispatcher settings and CDN configuration. Make sure your enabled vhost includes the correct ServerAlias for the static domain. For steps, refer to Frontend pipeline deployment breaks the website.

  12. If the pipeline fails with BUILD_NPM_AUDIT_ERROR, remove any conflicting SiteConfig or HtmlPageItemsConfig nodes. For steps, refer to How to resolve BUILD_NPM_AUDIT_ERROR in AEM as a Cloud Service front-end pipeline.

Notes

  • The FE-only pipeline enforces stricter code-style checks than full-stack Maven builds; all lint errors must be resolved before deployment.

  • You can automate the process of fixing JavaScript and CSS linting errors by adding the following script to your package.json:

    code language-none
    "scripts": {
      "lint:fix": "npm run lint:js:fix && npm run lint:css:fix"
    }
    

This allows you to run npm run lint:fix to automatically correct many linting problems before pushing changes.

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f