GoogleCloudPlatform / training-data-analyst

Labs and demos for courses for GCP Training (http://cloud.google.com/training).
Apache License 2.0
7.84k stars 5.85k forks source link

prepare_environment.sh breaks npm #2673

Open takotakot opened 1 week ago

takotakot commented 1 week ago
npm install -g npm@8.1.3

breaks Cloud Shell environment.

This issue affects Node.js labs for the Developing Application course.

ql_student@cloudshell:~/firebase/start (ql-project)$ npm install -g npm@8.1.3
npm error A complete log of this run can be found in: /home/ql_student/.npm/_logs/2024-09-22T02_09_43_085Z-debug-0.log
ql_student@cloudshell:~/firebase/start (ql-project)$ cat /home/ql_student/.npm/_logs/2024-09-22T02_09_43_085Z-debug-0.log
0 verbose cli /usr/local/nvm/versions/node/v20.17.0/bin/node /usr/local/nvm/versions/node/v20.17.0/bin/npm
1 info using npm@10.8.2
2 info using node@v20.17.0
3 silly config load:file:/usr/local/nvm/versions/node/v20.17.0/lib/node_modules/npm/npmrc
4 silly config load:file:/home/ql_student/.npmrc
5 silly config load:file:/usr/local/nvm/versions/node/v20.17.0/etc/npmrc
6 verbose title npm install npm@8.1.3
7 verbose argv "install" "--global" "npm@8.1.3"
8 verbose logfile logs-max:10 dir:/home/ql_student/.npm/_logs/2024-09-22T02_09_43_085Z-
9 verbose logfile /home/ql_student/.npm/_logs/2024-09-22T02_09_43_085Z-debug-0.log
10 silly logfile done cleaning log files
11 http fetch GET 200 https://registry.npmjs.org/npm 219ms (cache miss)
12 silly packumentCache heap:2197815296 maxSize:549453824 maxEntrySize:274726912
13 silly idealTree buildDeps
14 silly fetch manifest npm@8.1.3
15 silly packumentCache full:https://registry.npmjs.org/npm cache-miss
16 http fetch GET 200 https://registry.npmjs.org/npm 900ms (cache miss)
17 silly packumentCache full:https://registry.npmjs.org/npm set size:undefined disposed:false
18 silly placeDep ROOT npm@8.1.3 OK for:  want: 8.1.3
19 silly reify mark retired [
19 silly reify   '/usr/local/nvm/versions/node/v20.17.0/lib/node_modules/npm',
19 silly reify   '/usr/local/nvm/versions/node/v20.17.0/bin/npm',
19 silly reify   '/usr/local/nvm/versions/node/v20.17.0/bin/npx'
19 silly reify ]
20 silly reify moves {
20 silly reify   '/usr/local/nvm/versions/node/v20.17.0/lib/node_modules/npm': '/usr/local/nvm/versions/node/v20.17.0/lib/node_modules/.npm-S0MiAYLP',
20 silly reify   '/usr/local/nvm/versions/node/v20.17.0/bin/npm': '/usr/local/nvm/versions/node/v20.17.0/bin/.npm-HjWP77bP',
20 silly reify   '/usr/local/nvm/versions/node/v20.17.0/bin/npx': '/usr/local/nvm/versions/node/v20.17.0/bin/.npx-ZlH3Qvwz'
20 silly reify }
21 verbose cwd /home/ql_student/training-data-analyst/courses/developingapps/v1.3/nodejs/firebase/start
22 verbose os Linux 6.1.100+
23 verbose node v20.17.0
24 verbose npm  v10.8.2
25 verbose exit 1
26 verbose code 1
27 error A complete log of this run can be found in: /home/ql_student/.npm/_logs/2024-09-22T02_09_43_085Z-debug-0.log

ql_student@cloudshell:~/firebase/start (ql-project)$ npm
bash: /usr/local/nvm/versions/node/v20.17.0/bin/npm: No such file or directory

If we comment out the line, it works. e.g. # npm install -g npm@8.1.3

git grep -n "npm install -g npm@8.1.3"
courses/developingapps/v1.3/nodejs/appengine/end/prepare_environment.sh:34:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/appengine/start/prepare_environment.sh:34:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/cloudendpoints/bonus/prepare_environment.sh:28:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/cloudendpoints/bonus/prepare_environment.sh:75:gcloud compute ssh endpoint-host --zone us-central1-a --command "export PORT=8081 && export GCLOUD_PROJECT=$(gcloud info --format='value(config.project)') && export GCLOUD_BUCKET=$GCLOUD_PROJECT-media && cd ~/quiz-api && sudo npm install -g npm@8.1.3 && sudo npm update && npm start"
courses/developingapps/v1.3/nodejs/cloudendpoints/end/prepare_environment.sh:29:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/cloudendpoints/end/prepare_environment.sh:63:gcloud compute ssh endpoint-host --zone us-central1-a --command "export PORT=8081 && export GCLOUD_PROJECT=$(gcloud info --format='value(config.project)') && export GCLOUD_BUCKET=$GCLOUD_PROJECT-media && cd ~/quiz-api && sudo npm install -g npm@8.1.3 && sudo npm update && npm start"
courses/developingapps/v1.3/nodejs/cloudendpoints/end/prepare_environment.sh:64:#gcloud compute ssh endpoint-host --zone us-central1-a --command "export PORT=8081 && export GCLOUD_PROJECT=$DEVSHELL_PROJECT_ID && export GCLOUD_BUCKET=$DEVSHELL_PROJECT_ID-media && cd ~/quiz-api && sudo npm install -g npm@8.1.3 && sudo npm update && npm start"
courses/developingapps/v1.3/nodejs/cloudendpoints/start/prepare_environment.sh:40:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/cloudfunctions/bonus/prepare_environment.sh:25:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/cloudfunctions/end/prepare_environment.sh:25:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/cloudstorage/end/prepare_environment.sh:21:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/cloudstorage/start/prepare_environment.sh:21:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/containerengine/bonus/prepare_environment.sh:25:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/containerengine/end/prepare_environment.sh:25:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/firebase/end/prepare_environment.sh:25:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/firebase/start/prepare_environment.sh:25:# npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/pubsub-languageapi-spanner/bonus/prepare_web_environment.sh:25:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/pubsub-languageapi-spanner/end/prepare_web_environment.sh:25:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/stackdriver-debug-errorreporting/bonus/prepare_environment.sh:25:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/stackdriver-debug-errorreporting/end/prepare_environment.sh:25:npm install -g npm@8.1.3
courses/developingapps/v1.3/nodejs/stackdriver-debug-errorreporting/start/prepare_incomplete_environment.sh:25:npm install -g npm@8.1.3