AEM Cloud Service pipeline build failures due to Webpack and @types/node TypeScript errors

✨ This content is AI generated and could be inaccurate. Generative AI Terms

This article explains how to resolve pipeline build failures in Adobe Experience Manager (AEM) as a Cloud Service when Webpack reports TypeScript errors related to the @types/node dependency.

Description description

Environment

Adobe Experience Manager (AEM) as a Cloud Service (all versions)

Symptoms

  • Pipeline executions in Cloud Manager fail at the Build and Unit Testing stage.
  • Build logs show Webpack reporting multiple TypeScript syntax errors inside node_modules/@types/node/ffi.d.ts.
  • Wildcard (glob) imports in SCSS and TypeScript are not resolving to any files.
  • A dependency type definition file could not be retrieved.
  • The errors are not present in the project’s own code but in an installed package.
  • Example error: ERROR in node_modules/@types/node/ffi.d.ts:50:13 TS1005: ';' expected.
  • The build step uses npm install instead of npm ci, so the lock file is not enforced and the latest versions of dependencies are installed.
  • The build uses Node 16.17 / npm 8.15. npm warns that some packages require Node 18–20 or later.
  • No recent code changes were made to the repository.
  • Disabling the Reference Demo Add-on does not resolve the issue.
  • The issue is reproducible with every pipeline run.

Cause

The build pipeline installs the latest version of @types/node, which uses newer TypeScript syntax incompatible with the project’s older TypeScript version. This results in TypeScript syntax errors during Webpack compilation. Not enforcing the lock file allows incompatible dependency versions to be installed.

Resolution resolution

Follow the steps below to resolve the issue.

  1. In ui.frontend/package.json, add the following to the overrides section:
"overrides": {
  "@types/node": " 16.18.0"
}
  1. Add @types/node as a dev dependency at version 16.18.0.
  2. Change the npm command in your build pipeline from npm install to npm ci to ensure the lock file is used.
  3. Commit package-lock.json to your repository to lock dependency versions.
  4. (Optional) Consider upgrading Node to version 20 or 22, as Node 16 is end-of-life and some dependencies require newer versions.
  5. (Optional) Upgrade TypeScript and ts-loader to version 5.x if your project supports it.

After making these changes, run the pipeline again to verify that the build completes successfully.

recommendation-more-help
experience-cloud-kcs-help-kbarticles