I want to check whether my.env file has environmental file APP_KEY or not. If it doesn't have APP_KEY, then I am going to create a new one and save the data in.emv fikey This is my following code:-
const generateApiKey = require('generate-api-key');
const fs = require('fs');
const envfile = require('envfile');
const envSourcePath = '.env';
const IS_APP_KEY = process.env.APP_KEY;
if(IS_APP_KEY == null || IS_APP_KEY == '')
{
let parsedEnvFile = envfile.parseFileSync(envSourcePath);
parsedEnvFile.APP_KEY = generateApiKey();
fs.writeFileSync('./.env', envfile.stringifySync(parsedEnvFile))
}
However, I am keep getting an error:- parseFileSync() is not a function
How can I solve the problem?
the method doesn't exist, it's removed with v6.0.0
v6.0.0 2020 May 21
Breaking Changes:
API is now only stringify and parse
https://github.com/bevry/envfile/blob/master/HISTORY.md#v600-2020-may-21
so either install older version, or use new methods
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.