在我的 sails 应用程序中安装sails-hook-babel
以尝试在我的后端使用 es6 js 后,我无法启动我的应用程序。我收到一个错误:ReferenceError: regeneratorRuntime is not defined
寻找解决方案后,我尝试通过创建一个config/babel/js
文件来使用@bable/polyfill
:
module.exports.babel = {
polyfill: true
}
完成此操作后,应用程序将毫无错误地启动,但是当我尝试调用引用exits
属性的任何action2
格式操作时,如下所示:
fn: async function (inputs, exits) {
let mauticConnector = new MauticConnector({
apiUrl: sails.config.mauticUrl,
username: sails.config.mauticUser,
password: sails.config.mauticPw,
logLevel: 'verbose',
timeoutInSeconds: 5
});
const campaigns = (await mauticConnector.campaigns.listCampaigns()).campaigns;
// All done.
return exits.success(campaigns);
我收到错误UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'success' of undefined
在 2020 年,我可以做些什么来使sails-hook-babel
与我的应用配合使用?
使用节点 10 和 sails 1.0
Node 本身已经支持 ES6 的使用。你不需要使用 Babel 来处理这个问题。只需卸载软件包即可。