I'm new to Node.js and NPM and I'm trying to spin up a local dev from a Git repository. After installing the correct versions of Node and NPM when I'm testing the server.js
file but I get output that says that ENV vars are missing.
The server.js
file has this snippet:
require('require-environment-variables')([
'JWT_SECRET',
'PROXY_URL',
]);
I have found a .travis.yml
file an I have set the following:
env:
- JWT_SECRET=xxxxx PROXY_URL=http://foo.com
However the vars are not being read because I always no matter what get a message that ENV vars are missing, this is fired by:
for (var i = 0; i < variableArray.length; i++) {
if (!process.env[variableArray[i]]) {
missingVariables.push(variableArray[i]);
}
}
if (missingVariables.length) {
console.error('Environment variables needed:', JSON.stringify(missingVariables));
throw new Error('Environment variables missing');
}
Does my approach look correct?