NPM preinstall script fails on circleci

My nodejs app has a preinstall script that installs stuff needed for it to run on top of GCP AppEngine:

"preinstall": "apt-get update && apt-get -y install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget"

However, CircleCI fails to run the preinstall script with the following error:

W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/

I actually don’t really need to run this on the during the CI process - how can I prevent CircleCI to run the preinstall script? or maybe add a condition that identifies the CircleCI environment and not run all the installations?

Many thanks!

In the script, you can check for an environment variable (envar). Within many CI providers including CircleCI, the envar CI will be set and its value be true. The script can check for that at the start and quit if that envar is set to true.