Skip to content

prepare script does not read env_variables #1497

@pnicorelli

Description

@pnicorelli

Hi all,

I'm not sure this issue is ONTOPIC, I just use some code from your example.

I have some issue to get the process.env from a prepare script in package.json.
I'm trying to run mysql migration before starting the app but I can not fetch the process.env variables

My package.json

...
  "scripts": {
     ...
    "prepare": "npm run gcp-build",
    "gcp-build": "node migrations.js",
  },
...

My migrations.js

var path = require('path')
var mysql = require('mysql')
var migration = require('mysql-migrations')

require('dotenv').config()

var connection = mysql.createPool({
  connectionLimit: 10,
  host: process.env.DB_HOST,
  user: process.env.DB_USER,
  password: process.env.DB_PASS,
  database: process.env.DB_NAME
})

migration.init(connection, path.join(__dirname, '/migrations'))

My app read the env_variables from app.yaml without problem but the prepare script do not.

Any help will be appreciated.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions