CodeCommit pipeline fails after deployed from CDK

0

We have an infrastructure policy in our organisation which handles roles and policies for users and their groups. Up until a week ago it was working fine, all of a suden we got an error of CompileError: WebAssembly.Module(): invalid value type 'externref', enable with --experimental-wasm-reftypes @+139

Full error:

[Container] 2025/06/10 07:38:43.823217 Entering phase INSTALL
[Container] 2025/06/10 07:38:44.010047 Running command npm install -g aws-cdk@2
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'aws-cdk@2.1018.0',
npm WARN EBADENGINE   required: { node: '>= 18.0.0' },
npm WARN EBADENGINE   current: { node: 'v16.20.2', npm: '8.19.4' }
npm WARN EBADENGINE }

added 1 package, and audited 2 packages in 2s

found 0 vulnerabilities

[Container] 2025/06/10 07:38:57.567134 Phase complete: INSTALL State: SUCCEEDED
[Container] 2025/06/10 07:38:57.567159 Phase context status code:  Message: 
[Container] 2025/06/10 07:38:57.600748 Entering phase PRE_BUILD
[Container] 2025/06/10 07:38:57.602280 Phase complete: PRE_BUILD State: SUCCEEDED
[Container] 2025/06/10 07:38:57.602304 Phase context status code:  Message: 
[Container] 2025/06/10 07:38:57.635095 Entering phase BUILD
[Container] 2025/06/10 07:38:57.636458 Running command cdk -a . deploy ProdPoliciesInfrastructureStack --require-approval=never --verbose
/usr/local/lib/node_modules/aws-cdk/lib/index.js:318057
    var wasmModule = new WebAssembly.Module(bytes);
                     ^

CompileError: WebAssembly.Module(): invalid value type 'externref', enable with --experimental-wasm-reftypes @+139
    at ../../node_modules/cdk-from-cfn/index.js (/usr/local/lib/node_modules/aws-cdk/lib/index.js:318057:22)
    at __require (/usr/local/lib/node_modules/aws-cdk/lib/index.js:17:50)
    at lib/commands/migrate.ts (/usr/local/lib/node_modules/aws-cdk/lib/index.js:319064:28)
    at __init (/usr/local/lib/node_modules/aws-cdk/lib/index.js:14:56)
    at lib/cli/cdk-toolkit.ts (/usr/local/lib/node_modules/aws-cdk/lib/index.js:319350:5)
    at __init (/usr/local/lib/node_modules/aws-cdk/lib/index.js:14:56)
    at lib/cli/cli.ts (/usr/local/lib/node_modules/aws-cdk/lib/index.js:355329:5)
    at __init (/usr/local/lib/node_modules/aws-cdk/lib/index.js:14:56)
    at Object.<anonymous> (/usr/local/lib/node_modules/aws-cdk/lib/index.js:355577:14)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)

[Container] 2025/06/10 07:38:58.559497 Command did not exit successfully cdk -a . deploy ProdPoliciesInfrastructureStack --require-approval=never --verbose exit status 1
[Container] 2025/06/10 07:38:58.562876 Phase complete: BUILD State: FAILED
[Container] 2025/06/10 07:38:58.562892 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: cdk -a . deploy ProdPoliciesInfrastructureStack --require-approval=never --verbose. Reason: exit status 1
[Container] 2025/06/10 07:38:58.597064 Entering phase POST_BUILD
[Container] 2025/06/10 07:38:58.598907 Phase complete: POST_BUILD State: SUCCEEDED
[Container] 2025/06/10 07:38:58.598921 Phase context status code:  Message: 
[Container] 2025/06/10 07:38:58.662763 Set report auto-discover timeout to 5 seconds
[Container] 2025/06/10 07:38:58.662901 Expanding base directory path:  .
[Container] 2025/06/10 07:38:58.665250 Assembling file list
[Container] 2025/06/10 07:38:58.665265 Expanding .
[Container] 2025/06/10 07:38:58.667702 Expanding file paths for base directory .
[Container] 2025/06/10 07:38:58.667719 Assembling file list
[Container] 2025/06/10 07:38:58.667723 Expanding **/*
[Container] 2025/06/10 07:38:58.670351 No matching auto-discover report paths found
[Container] 2025/06/10 07:38:58.670431 Report auto-discover file discovery took 0.007668 seconds
[Container] 2025/06/10 07:38:58.670446 Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED
[Container] 2025/06/10 07:38:58.670500 Phase context status code:  Message: 

package.json:

{
  "name": "nordic-annalect-policies-infrastructure",
  "version": "0.1.0",
  "bin": {
    "nordic-annalect-policies-infrastructure": "bin/nordic-annalect-policies-infrastructure.js"
  },
  "scripts": {
    "build": "tsc",
    "watch": "tsc -w",
    "test": "jest",
    "cdk": "cdk"
  },
  "devDependencies": {
    "@types/jest": "^29.4.4",
    "@types/node": "^18.15.3",
    "eslint": "^8.36.0",
    "eslint-config-prettier": "^8.7.0",
    "eslint-plugin-prettier": "^4.2.1",
    "jest": "^29.5.0",
    "prettier": "^2.8.4",
    "ts-jest": "^29.0.5",
    "ts-node": "^10.9.1",
    "typescript": "^4.9.5"
  },
  "dependencies": {
    "aws-cdk": "^2.69.0",
    "aws-cdk-lib": "^2.69.0",
    "constructs": "^10.1.279",
    "electron-to-chromium": "^1.4.331",
    "outdated": "^0.1.1",
    "source-map-support": "^0.5.21"
  },
  "jest": {
    "moduleFileExtensions": [
      "js"
    ]
  }
}

Not sure where this came from as we didn't update anything or added anything new. Can someone help me out on this one?

1 Answer
0

The error you're encountering is related to a Node.js version compatibility issue with the AWS CDK. The error message shows that you're using Node.js v16.20.2, but the AWS CDK version you're trying to use requires Node.js 18.0.0 or higher.

The specific error CompileError: WebAssembly.Module(): invalid value type 'externref', enable with --experimental-wasm-reftypes @+139 is occurring because newer versions of the CDK use WebAssembly features that are not supported in Node.js 16.

There are a few ways to resolve this issue:

  1. Upgrade the Node.js version in your build environment to version 18 or higher. This is the recommended approach since your package.json shows you're using AWS CDK v2.69.0 which requires Node.js 18+.

  2. If you can't upgrade Node.js, you could try pinning to an older version of the CDK that's compatible with Node.js 16. However, this is not recommended as a long-term solution.

  3. Update your CodeBuild project configuration to use a newer runtime that includes Node.js 18+.

The warning in your logs clearly indicates this compatibility issue:

npm WARN EBADENGINE Unsupported engine {
package: 'aws-cdk@2.1018.0',
required: { node: '>= 18.0.0' },
current: { node: 'v16.20.2', npm: '8.19.4' }
}

This is a common issue when the CDK is updated but the build environment isn't updated to match the new requirements.
Sources
Problem: Core pipeline failure - Landing Zone Accelerator on AWS

answered 13 days ago
AWS
SUPPORT ENGINEER
reviewed 12 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions