Good Evening,
I am trying to deploy my Angular app to Heroku via the Gitlab CI. I have an API key saved in the environment file that is in Angular. I am creating the folder and file in my Gitlab CI, but I am getting the below errors:
src/main.ts:5:29 - error TS2307: Cannot find module './environments/environment' or its corresponding type declarations.
5 import { environment } from './environments/environment';
Error: "An unhandled exception occurred: The /tmp/build_eef7fc3b/src/environments/environment.prod.ts path in file replacements does not exist.
See "/tmp/ng-V6VwXu/angular-errors.log" for further details."
From the Gitlab output:
"$ ls -ld "$TP/"*
-rw-r--r--. 1 root root 103 Jan 15 00:38 ./src/environments/environment.prod.ts
-rw-r--r--. 1 root root 104 Jan 15 00:38 ./src/environments/environment.ts"
It seems as though that Gitlab went from the directory that I want to a tmp folder. I am not sure how to access that particular folder or why its changing. I have my .yml file below as well.
Thank you for your time and help.
# For the testing stage you must include all those lines so the tests run and finish. If ng test doesnt have the flags that come after it, it will hang on that stage.
image: node:latest
before_script:
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
stages:
- production
production:
type: deploy
stage: production
image: ruby:latest
script:
- pwd
- (which ifconfig) || apt install net-tools
- ifconfig
- (which dig) || apt install dnsutils
- dig +short myip.opendns.com @resolver1.opendns.com
- TP=./src/environments
- TF="$TP/environment.ts"
- PE="$TP/environment.prod.ts"
- echo "$PE"
- mkdir -p "$TP"
- realpath "$PE"
- echo "$TF"
- printf "export const environment = {
production:false,
youtube:'%s'
};
" "$youtube" > "$TF"
- printf "export const environment = {
production:true,
youtube:'%s'
};
" "$youtube" > "$PE"
- cat "$TF"
- cat "$PE"
- ls -ld "$TP/"*
- ls -ld /tmp/*
- dpl --provider=heroku --app=$HEROKU_APP_PRODUCTION --api-key=$HEROKU_API_KEY
only:
- master
#- pwd
#- find .
#- TP=./src/environments
#- TF="$TP/environment"
#- PE="$TP/environment.prod.ts"
# - mkdir -p "$TP"
#- printf "export const environment = {
production:false,
youtube:'%s'
};
" "$youtube" > "$TF"
#- printf "export const environment = {
production:true,
youtube:'%s'
};
" "$youtube" > "$PE"
#- cat "$TF"
# - cat "$PE"
# - cp "$TF" "$TF".ts
# - echo "youtube=$youtube" > .env
# - echo "youtube=$youtube" > .env
question from:
https://stackoverflow.com/questions/65713928/deploying-angular-app-using-the-gitlab-ci-causes-an-error-in-the-tmp-directory 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…