【发布时间】:2020-11-14 20:03:50
【问题描述】:
大家好,我有以下问题,在编译项目时我收到一条错误消息: src / app / cart / cart.component.ts (63.25) 中的错误:错误 TS2304: 找不到名称 'require'。 我已经尝试实现 npm install --save @ types / node 还要检查 tsconfig.app.json 配置,但错误仍然存在。我该如何解决? 我正在用 Angular 开发一切。 感谢您的帮助
const mercadopago = require('mercadopago');
mercadopago.configure({
access_token: 'Your key'
});
let preference = {
items: [
{
title: 'Mi producto',
unit_price: 100,
quantity: 1,
}
]
};
mercadopago.preferences.create(preference)
.then(function (response) {
this.global.init_point = response.init_point;
}).catch(function (error) {
console.log(error);
});
}
【问题讨论】:
-
mercadopago是一个 Node.js API。因此,您需要创建一个 Node.js 应用程序并在我们的后端实现中使用它。你在我们的 Angular 应用程序中使用的接缝。
标签: node.js angular typescript mercadopago mercadopagosdk