Clarifai / clarifai-javascript

Official Clarifai JavaScript client for browsers and node.js
https://docs.clarifai.com
Other
351 stars 81 forks source link

I can't use angular 7 or ionic project #30

Closed Alzmoth closed 5 years ago

Alzmoth commented 5 years ago

When i add clarifai in my angular project give me the this error

index.js:8 Uncaught ReferenceError: global is not defined at Object../node_modules/clarifai/dist/index.js (index.js:8) at webpack_require (bootstrap:78) at Module../src/app/home/home.component.ts (main.js:231) at webpack_require (bootstrap:78) at Module../src/app/app.module.ts (app.component.ts:8) at webpack_require (bootstrap:78) at Module../src/main.ts (main.ts:1) at webpack_require (bootstrap:78) at Object.0 (main.ts:12) at webpack_require (bootstrap:78)

i try clarifai version: 2.9.0 , 2.0.9

ionic project's error =>

cannot read property 'App' of undefined

I tried to define it in various ways but allways different error.

How can i use clarifa in ionic project ?? pls help me

rok-povsic commented 5 years ago

@Alzmoth Hi, googling around a bit I've found out that global and process variables were removed with Angular 6. The solution seems to be to add the following to your project's polyfills.ts file:

(window as any).global = window;
(window as any).process = {
  env: { DEBUG: undefined },
};

Please let me know if this fixes it for you.

rok-povsic commented 5 years ago

Closing due to lack of further input.