0

我不能在 Angular 7 中使用 clarifai 给我这个错误

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) 在webpack_require (bootstrap:78) 在 Module../src/app/app.module.ts (app.component.ts:8) 在webpack_require (bootstrap:78)在 Module../src/main.ts (main.ts:1) 在webpack_require (bootstrap:78) 在 Object.0 (main.ts:12) 在webpack_require (bootstrap:78)

这个 index.js

'使用严格';

var App = require('./App');

var _require = require('./../package.json'), version = _require.version;

module.exports = global.Clarifai = { 版本:版本,应用:应用,
GENERAL_MODEL: 'aaa03c23b3724a16a56b629203edc62c', FOOD_MODEL: 'bd367be194cf45149e75f01d59f77ba7', TRAVEL_MODEL: 'eee28c313d69466f836ab83287a54ed9', NSFW_MODEL: 'e9576d86d2004ed1a38ba0cf39ecb4b1', WEDDINGS_MODEL: 'c386b7a870114f4a87477c0824499348', WEDDING_MODEL: 'c386b7a870114f4a87477c0824499348', COLOR_MODEL: 'eeed0b6733a644cea07cf4c60f87ebb7', CLUSTER_MODEL: 'cccbe437d6e54e2bb911c6aa292fb072', FACE_DETECT_MODEL: 'a403429f2ddf4b49b307e318f00e528b', FOCUS_MODEL: 'c2cf7cecd8a6427da375b9f35fcd2381', LOGO_MODEL: 'c443119bf2ed4da98487520d01a0b1e3', DEMOGRAPHICS_MODEL: 'c0c0ac362b03416da06ab3fa36fb58e3', GENERAL_EMBED_MODEL: 'bbb5f41425b8468d9b7a554ff10f8581', FACE_EMBED_MODEL: 'd02b4508df58432fbb84e800597b8959', APPAREL_MODEL: 'e0be3b9d6a454f0493ac3a30784001ff', MODERATION_MODEL: 'd16f390eb32cad478c7ae150069bd2c6', TEXTURES_AND_PATTERNS: 'fbefb47f9fdb410e8ce14f24f54b47ff', LANDSCAPE_QUALITY: 'bec14810deb94c40a05f1f0eb3c91403', PORTRAIT_QUALITY: 'de9bd05cfdbf4534af151beb2a5d0953' };

我该如何解决这个错误

4

1 回答 1

1

放入 polyfills.ts

(window as any).global = window;

于 2019-05-02T22:59:13.747 回答