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 installinstead ofnpm 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.
- In
ui.frontend/package.json, add the following to theoverridessection:
"overrides": {
"@types/node": " 16.18.0"
}
- Add
@types/nodeas a dev dependency at version16.18.0. - Change the npm command in your build pipeline from
npm installtonpm cito ensure the lock file is used. - Commit
package-lock.jsonto your repository to lock dependency versions. - (Optional) Consider upgrading Node to version 20 or 22, as Node 16 is end-of-life and some dependencies require newer versions.
- (Optional) Upgrade TypeScript and
ts-loaderto version 5.x if your project supports it.
After making these changes, run the pipeline again to verify that the build completes successfully.