3
votes

I am trying to do a cound integration to my existing angular project

https://www.npmjs.com/package/kount-access-api

I Installed the NPM module and obviously it in JS and not TS and so i used the below lines in angular-cli.json

 "scripts": [
        "../node_modules/kount-access-api/lib/kount-access-api.js"
      ],

However i am getting below error in console,

Uncaught ReferenceError: require is not defined at eval (eval at webpackJsonp.../../../../script-loader/addScript.js.module.exports (addScript.js:9), :25:14) at eval () at webpackJsonp.../../../../script-loader/addScript.js.module.exports (addScript.js:9) at Object.../../../../script-loader/index.js!../../../../kount-access-api/lib/kount-access-api.js (kount-access-api.js?9331:1) at webpack_require (bootstrap a89535f…:54) at Object.2 (scripts.bundle.js:37) at webpack_require (bootstrap a89535f…:54) at webpackJsonpCallback (bootstrap a89535f…:25) at scripts.bundle.js:1

Any pointers is appreciated

1
did you try to remove and reinstall npm_modules? Seams like it is not a problem with kount-access-api itself. Uncaught ReferenceError: require is not defined that is a problem.angularrocks.com
I don't think it is the problem with Install. It is just that Angular -cli uses webpack internally that doesn't have RequireJS to handle require calls i assume. I dont know how to fix it though.Aravind R
I did install the latest cli and then installed kount-access-api and it worksangularrocks.com
@kuncevic can you please share the code because i cant get it to work. I tried removing and adding and also upgrading CLI.Aravind R
ahh sorry it is actually didn't work. Check my answer blow.angularrocks.com

1 Answers

1
votes

I just explored the library you are trying to reference and by checking its github page it is clearly says that it is nodejs library. Also I checked the code and it is referencing the Needle which is another nodejs library

/**
 * Required Libraries
 */
// needle is needed for http calls
var needle = require("needle");

Check out node_modules\kount-access-api\node_modules\.bin\ and you will see what I am talking about. So it won't work in a browser.

I have never used Kount but seams like you have to connect to Kount from server side, not from browser/client side.

Checkout these links:

https://github.com/Kount

http://kount.github.io/