Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing JS in Angular CLI 1.2.4

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

like image 472
Aravind R Avatar asked May 25 '26 13:05

Aravind R


1 Answers

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/

like image 148
angularrocks.com Avatar answered May 28 '26 03:05

angularrocks.com



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!