Question

App Platoform when add enviroment variables I have yarn command errors

Posted about 11 hours ago 25 views
Node.jsDigitalOcean App Platform

Hi, how are you?

I am starting to test this service that is really very good and I am encountering quite strange behaviors;

When I generate the basic application with the commands to run the application it works perfectly for me, obviously the difference is that the application fails because I clearly need to add the environment variables. When I add the environment variables the commands in the compilation step stop working for me.

This would be the YAML that the commands work.

alerts:
- disabled: true
  rule: DEPLOYMENT_FAILED
- rule: DOMAIN_FAILED
name: test-app
region: nyc
services:
- build_command: | -
    npm install pm2 -g
    yarn pre-build
    yarn tsc
  environment_slug: node-js
  github:
    branch: master
    deploy_on_push: true
    repo: dg / test-app
  http_port: 8080
  instance_count: 1
  instance_size_slug: basic-xs
  name: test-app
  routes:
  - path: /
  run_command: pm2-runtime start ecosystem.config.js
  source_dir: /

This would be the result.

Running custom build command: npm install pm2 -g
yarn pre-build
yarn tsc
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random () in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
/ layers / herokunodejs-engine / nodejs / bin / pm2-runtime -> / layers / herokunodejs-engine / nodejs / lib / nodemodules / pm2 / bin / pm2-runtime
/ layers / heroku
nodejs-engine / nodejs / bin / pm2 -> / layers / herokunodejs-engine / nodejs / lib / nodemodules / pm2 / bin / pm2
/ layers / herokunodejs-engine / nodejs / bin / pm2-dev -> / layers / herokunodejs-engine / nodejs / lib / nodemodules / pm2 / bin / pm2-dev
/ layers / heroku
nodejs-engine / nodejs / bin / pm2-docker -> / layers / herokunodejs-engine / nodejs / lib / nodemodules / pm2 / bin / pm2-docker
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (nodemodules / pm2 / nodemodules / chokidar / node_modules / fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {“os”: “darwin”, “arch”: “any”} (current: {“os”: “linux”, “arch”: “x64”})

  • pm2@5.1.2 added 181 packages from 200 contributors in 14.838s yarn run v1.22.17 $ cpy –cwd = src –parents ’** / ’ ’! * / *. ts’ ../dist/src Donate in 1.04s. yarn run v1.22.17 $ tsc Done in 10.19s.

This result makes all the sense since it works well, except that when the application is executed it asks me for the environment variables (obvious thing).

Now when I add the environment variables even just one for testing it throws me this error.

  • pm2@5.1.2 added 181 packages from 200 contributors in 15.583s yarn run v1.22.17 $ cpy –cwd = src –parents ’** / ’ ’! * / *. ts’ ../dist/src / bin / sh: 1: cpy: not found info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command failed with exit code 127. yarn run v1.22.17 $ tsc / bin / sh: 1: tsc: not found error Command failed with exit code 127. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. building: exit status 127 ERROR: failed to build: exit status 1

This would be the yaml for the latter case.

alerts:
- disabled: true
  rule: DEPLOYMENT_FAILED
- rule: DOMAIN_FAILED
name: test-app
region: nyc
services:
- build_command: | -
    npm install pm2 -g
    yarn pre-build
    yarn tsc
  environment_slug: node-js
  envs:
  - key: NODE_ENV
    scope: RUN_AND_BUILD_TIME
    value: production
  github:
    branch: master
    deploy_on_push: true
    repo: dg / test-app
  http_port: 8080
  instance_count: 1
  instance_size_slug: basic-xs
  name: test-app
  routes:
  - path: /
  run_command: pm2-runtime start ecosystem.config.js
  source_dir: /

In summary if I add environment variables it stops working for me.

Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!