【发布时间】:2019-05-28 03:41:48
【问题描述】:
我正在使用 Typescript,它从 src/ 编译到 lib/ 文件夹,以及 Babel,它从 lib/ 编译到 dist/。
我遇到的问题是,当我编译应用程序时,src/email_templates/ 中的 .handlebars 文件没有被复制到 dist/。因此,当我运行该应用程序时,由于 dist/email_templates/ 不存在而出现错误。
我正在使用nodemailer-handlebars 包并尝试将email_templates/ 文件夹移动到项目根目录并将viewPath 设置为该文件夹,但是这也失败了,因为应用程序位于var/www/api.my-domain.com/。似乎我在api.my-domain.com 文件夹名称中有句点导致 viewPath 失败并出现错误:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:125:11)
at Object.resolve (path.js:1080:7)
at ExpressHandlebars._resolveLayoutPath (/var/www/api.my-domain.com/node_modules/express-handlebars/lib/express-handlebars.js:342:17)
at ExpressHandlebars.<anonymous> (/var/www/api.my-domain.com/node_modules/express-handlebars/lib/express-handlebars.js:223:35)
这是我构建应用程序的 package.json 脚本:
"build": "tsc && babel ./lib --out-dir ./dist ",
如何更改它以删除dist/email_templates 的当前内容,然后将src/email_templates 的内容复制到dist/email_templates?
【问题讨论】:
标签: node.js typescript handlebars.js babeljs npm-scripts