我试图使用yaml库加载一个无服务器文件来进行一些预处理:
const yaml = require('js-yaml');
const file = await fs.readFile(path, { encoding: 'utf8' });
const doc = yaml.load(file);我收到了一个错误:
YAMLException: unknown tag !<!Ref> (26:42)因为这一行:
S3_BUCKET: !Ref ComposerBucket是否有可能以某种方式将无服务器文件加载到对象中?我在想,也许无服务器正在使用特定的模式,在加载时我需要定义这些模式,但我不知道。
const doc = yaml.load(file, { schema: 'serverless-framework' });你知不知道我怎样才能让这件事起作用?
发布于 2021-12-17 12:12:00
我在浏览无服务器npm包源代码时找到了解决方案:
const cloudformationSchema = require('@serverless/utils/cloudformation-schema');
const doc = yaml.load(file, { schema: cloudformationSchema });https://stackoverflow.com/questions/70391775
复制相似问题