From 4d752428d93b18b69c28acdbd9aa821a517db73a Mon Sep 17 00:00:00 2001 From: d-goog <188102366+d-goog@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:37:21 -0800 Subject: [PATCH] chore: fix `npm` for Node v18 samples tests (#2043) chore: fix `npm` for samples tests --- synthtool/gcp/templates/node_library/.kokoro/samples-test.sh | 4 +++- tests/fixtures/nodejs_mono_repo_esm/.kokoro/samples-test.sh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/synthtool/gcp/templates/node_library/.kokoro/samples-test.sh b/synthtool/gcp/templates/node_library/.kokoro/samples-test.sh index 59098966f..e07413af6 100755 --- a/synthtool/gcp/templates/node_library/.kokoro/samples-test.sh +++ b/synthtool/gcp/templates/node_library/.kokoro/samples-test.sh @@ -16,7 +16,9 @@ set -eo pipefail -export NPM_CONFIG_PREFIX=${HOME}/.npm-global +# Ensure the npm global directory is writable, otherwise rebuild `npm` +mkdir -p $NPM_CONFIG_PREFIX +npm config -g ls || npm i -g npm@`npm --version` # Setup service account credentials. export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secret_manager/long-door-651-kokoro-system-test-service-account diff --git a/tests/fixtures/nodejs_mono_repo_esm/.kokoro/samples-test.sh b/tests/fixtures/nodejs_mono_repo_esm/.kokoro/samples-test.sh index 950f84834..c6551d57d 100644 --- a/tests/fixtures/nodejs_mono_repo_esm/.kokoro/samples-test.sh +++ b/tests/fixtures/nodejs_mono_repo_esm/.kokoro/samples-test.sh @@ -16,7 +16,9 @@ set -eo pipefail -export NPM_CONFIG_PREFIX=${HOME}/.npm-global +# Ensure the npm global directory is writable, otherwise rebuild `npm` +mkdir -p $NPM_CONFIG_PREFIX +npm config -g ls || npm i -g npm@`npm --version` # Setup service account credentials. export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json