Syntax error: word unexpected (expecting ")") in esbuild

We’ve been using a machine executor to run builds for our Angular v11.2.0 app. After updating to Angular v12.2.2, Angular now requires minimum Node version of 12.14.0. So, I updated our CircleCI config to use Node 12.14.0 (also tried 12.22.5 and 14.15.4), but now our builds error out in /home/circleci/repo/node_modules/esbuild/bin/esbuild which appears to be trying to process files that have bad syntax:

/home/circleci/repo/node_modules/esbuild/bin/esbuild: 1: /home/circleci/repo/node_modules/esbuild/bin/esbuild: �����H__PAGEZEROx__TEXT�t�t__text__TEXT�B�__symbol_stub1__TEXT: not found
/home/circleci/repo/node_modules/esbuild/bin/esbuild: 2: /home/circleci/repo/node_modules/esbuild/bin/esbuild: Cy�: not found
/home/circleci/repo/node_modules/esbuild/bin/esbuild: 3: /home/circleci/repo/node_modules/esbuild/bin/esbuild: Syntax error: word unexpected (expecting ")")

Here’s our config.yml:

# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
  build:
    # Using machine executor for more memory
    machine:
        # recommended linux image - includes Ubuntu 16.04, docker 18.09.3, docker-compose 1.23.1
        image: ubuntu-1604:201903-01

    working_directory: ~/repo

    steps:
      - checkout

      - run:
          # Using machine executor, we need to install needed Node version
          name: Installing Node 14.15.4
          # Load installed nvm env first, in each step
          command: |
            export NVM_DIR="/opt/circleci/.nvm"
            [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
            nvm install v14.15.4
            nvm alias default v14.15.4

      - run:
          name: Building for dev
          # Load installed nvm env first, in each step
          command: |
            export NVM_DIR="/opt/circleci/.nvm"
            [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
            npm run build -- --progress=false

      - run:
          name: Building for prod (AOT)
          # Load installed nvm env first, in each step
          command: |
            export NVM_DIR="/opt/circleci/.nvm"
            [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
            npm run build -- --configuration=production --progress=false

Any ideas?

Thank you!

I don’t know why it was happening, but the errors were due to the CircleCI image using the checked out /node_modules/esbuild binary file, which in this case was generated on my MacOS (darwin-64 architecture). When the CircleCI image tries to execute it as linux-64 architecture, it throws the error. My solution was to add an npm rebuild esbuild command in the install Node step, to generate the esbuild binary on the CircleCI image.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.