JS import in Angular CLI 1.2.4

I am trying to integrate cound with my existing angular project

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

I have installed the NPM module and obviously it is 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,

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

Any pointers are appreciated

+3


source to share


1 answer


I just looked into the library you are trying to link and checking its github page clearly states that it is a library.Also nodejs

I checked the code and links to Needle which is another nodejs

library

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

      

Check node_modules\kount-access-api\node_modules\.bin\

out and you will see what I am talking about. Therefore it will not work in the browser.

I've never used Kount, but seams is how you should connect to Kount from the server side and not from the browser / client.



Check out these links:

https://github.com/Kount

http://kount.github.io/

+1


source







All Articles