I am using nconf
in a NodeJS project, which I want to deploy to AWS Lambda using claudia.js. I have followed this example:
const path = require('path');
const nconf = require('nconf');
function Configuration(){
nconf.argv().env({ lowerCase: true, separator: '_' });
let defaultJsonPath = path.join(__dirname, 'default.json');
console.log(`Using default config at ${defaultJsonPath}`);
nconf.file("default", defaultJsonPath);
}
Configuration.prototype.get = function(key) {
return nconf.get(key);
};
module.exports = new Configuration();
This code works perfectly fine when testing on my local machine using claudia-local-api
.
However, when I try to deploy to Lambda using claudia create ..
it simply stops at validating package
without any errors.
claudia create --verbose --profile wgmtest --version dev --region eu-west-1 --api-module app
packaging files npm install -q --no-audit --production
npm WARN claudia@1.0.0 No description
npm WARN claudia@1.0.0 No repository field.
added 21 packages from 18 contributors in 0.339s
2 packages are looking for funding
run `npm fund` for details
validating package
5.12.0
If I export a class
instead of a function
, the claudia create
command works fine (see below). I'd like to understand what the issue is here, or at least how I can get some additional log output of the problem.
const path = require('path');
const nconf = require('nconf');
class Configuration {
constructor() {
nconf.argv().env({ lowerCase: true, separator: '_' });
let defaultJsonPath = path.join(__dirname, 'default.json');
console.log(`Using default config at ${defaultJsonPath}`);
nconf.file("default", defaultJsonPath);
}
static get(key) {
return nconf.get(key);
}
}
module.exports = Configuration;
question from:
https://stackoverflow.com/questions/65942202/why-does-claudia-js-fail-package-validation-when-using-nconf-in-a-specific-way 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…