I have 3 companies I would like to upgrade to v4, after the update I cannot seem to load variables into the serverless.json (JSON version of serverless.yml). After the update I get this error:
Failed to resolve variable './config/serverlessConfig.js#getEnv.stage' with resolver 'file' and provider 'file': Error: Cannot load or execute JS module "C:\dev\heal-
api\config\serverlessConfig.js": Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
This is a node error I think. I’m running node 20.
My variable comes from a file that exports a function that returns an object.
const config = {
development:{
//variables
}
}
export function getEnv() {config[process.env.BUILD_ENV]);
return Object.assign({}, config[process.env.BUILD_ENV]);
}
My serverless.json look like this:
{
"service": "healPay",
"plugins": [
"serverless-webpack",
"serverless-offline",
"serverless-prune-plugin",
"serverless-domain-manager"
],
"custom": {
"customDomain": {
"certificateName": "${file(./config/serverlessConfig.js):getEnv.certificateName}",
/// rest