Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
103 views
in Technique[技术] by (71.8m points)

node.js - Why does claudia.js fail package validation when using nconf in a specific way?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...