0

I've been running an angular application on a google cloud app engine service for a few years. I made no changes to my .yaml file or anything related to my node versions and in my deployment pipeline today I have this error when trying to deploy:

Step #4: node: --openssl-legacy-provider is not allowed in NODE_OPTIONS

I've found a few hits on google for this error but all of the resolutions seem to be for getting the application to run locally on my dev environment.

one of the solutions said to run:

unset NODE_OPTIONS

but I"m not sure that's applicable for me since I'm trying to deploy onto a google cloud hosted app service.

I tried updating my node version in my .yaml file just to see if it would fix it (from 10 to 12 and then 12 to 16) nothing works.

I"ve also deleted package-lock.json and reinstalled everything, no joy.

Here is my relevant scripts in package.json:

"scripts": {
        "ng": "ng",
        "start": "ng serve --ssl --ssl-key c:\\SelfSignedCertificate\\localhost.key --ssl-cert c:\\SelfSignedCertificate\\localhost.crt",
        "start:prod": "node dist/myapp/server.js --openssl-legacy-provider",
        "build": "export NODE_OPTIONS=--openssl-legacy-provider; ng build --prod && ncp server.js dist/myapp/server.js",
        "build:local": "ng build",
        "test": "ng test",
        "test:headless": "ng test --watch=false --browsers=ChromeHeadless",
        "lint": "ng lint",
        "e2e": "npm run pre-e2e && ng e2e --webdriver-update=false",
        "pre-e2e": "webdriver-manager update --standalone false --gecko false --versions.chrome 86.0.4240.22"
    },

TIA

EDIT: I just tried a deployment on a completely different application (in a completely different GCP account) that has had no changes made to it and the same error occurs so GCP must have changed something today (I ran several successful builds yesterday). Can anyone think of a workaround or a solution?

Blair Holmes
  • 1,521
  • 2
  • 22
  • 35
  • Can you check the suggestions in this [link1](https://stackoverflow.com/a/76089057/18265638 ) ,[link2](https://bobbyhadz.com/blog/node-openssl-legacy-provider-is-not-allowed-in-node-options) & [github](https://github.com/vaadin/flow/issues/13889) – Sathi Aiswarya Apr 26 '23 at 07:43
  • I have seen all of those posts and as mentioned in my OP tried changing node versions and playing around with unsetting the parameter. – Blair Holmes Apr 26 '23 at 13:12

2 Answers2

0

I was able to find a workaround for now. In package.json, I in the scripts section, I removed the export NODE_OPTIONS flag so this:

"build": "export NODE_OPTIONS=--openssl-legacy-provider; ng build --prod && ncp server.js dist/spaces-angular/server.js",

becomes this

"build": "ng build --prod && ncp server.js dist/spaces-angular/server.js",

I also had to specify which node version I wanted to use to build in my cloudbuild.yaml file. I added node 12.18.3 in two places:

steps:
# copy yaml from bucket
- name: gcr.io/cloud-builders/gsutil
  args: ['cp', 'gs://$_BUCKET/app-development.yaml', 'app.yaml']
# copy environment from bucket
- name: gcr.io/cloud-builders/gsutil
  args: ['cp', 'gs://$_BUCKET/environment.development.ts', 'src/environments/environment.prod.ts']
# Install dependencies
- name: node:12.18.3
  entrypoint: npm
  args: ['install']
# Run custom commands
- name: 'gcr.io/cloud-builders/npm:node-12.18.3'
  args: [ 'run', 'build', '--prod' ]
# Deploy to google cloud app egnine
- name: 'gcr.io/cloud-builders/gcloud'
  args: ['app', 'deploy', '--version=prod']
timeout: 1h
Blair Holmes
  • 1,521
  • 2
  • 22
  • 35
0

If you cannot update your node version, then you just need to add the env stage just before you run your build command in cloudbuild.yml file:

steps:

#build angular app

- name: "gcr.io/cloud-builders/npm"

      env:
    
      - 'NODE_OPTIONS=--openssl-legacy-provider'

  args: ['run','build-prod']

  dir: 'code/'

This worked for me!

Lazy_bug
  • 1
  • 2