0
我有一個angular2應用程序,我需要使用付款API。找不到名稱'require'。 ANGULAR 2
https://stripe.com/docs/quickstart
在上的NodeJS部分此代碼示例他們說,使用這樣的:
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
var stripe = require("stripe")("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
// Token is created using Stripe.js or Checkout!
// Get the payment token submitted by the form:
var token = request.body.stripeToken; // Using Express
// Charge the user's card:
var charge = stripe.charges.create({
amount: 1000,
currency: "usd",
description: "Example charge",
source: token,
}, function(err, charge) {
// asynchronously called
});
我們安裝requireJS與NPM,但是當我們運行它,我們得到這個錯誤:
Cannot find name 'require'.
L48: pagar() { L49: var stripe = require("stripe")("sk_test_ayzCMDmjq2QOIW0s3dTihxNR");
它看起來像解決了需求問題,但是現在我得到這個錯誤:Uncaught TypeError:__webpack_require __(...)。createServer不是一個函數 –