在 angular 2/4 中使用 UMD 库
use UMD library in angular 2/4
我有库(Tus.io) thats compiled to UMD。我的 Angular2/4 项目需要它。当我用 npm 安装它时(npm install tus-js-client ) 并导入它 (var tus = require("tus-js-client"); ) 我得到的错误是:
Failed to compile.
/home/***/src/app/manageVideos/Partials/add.component.ts (8,17):
Module '../../../../node_modules/tus-js-client/dist/tus.js'
was resolved to '/home/***/node_modules/tus-js-client/dist/tus.js',
but '--allowJs' is not set.
/home/***/src/app/manageVideos/Partials/add.component.ts (9,11): Cannot find name 'require'.
解决您问题的最简单方法是安装 TypeScript 声明:
npm install @types/tus-js-client --save-dev
并像这样导入它:
import * as tus from "tus-js-client";
我有库(Tus.io) thats compiled to UMD。我的 Angular2/4 项目需要它。当我用 npm 安装它时(npm install tus-js-client ) 并导入它 (var tus = require("tus-js-client"); ) 我得到的错误是:
Failed to compile.
/home/***/src/app/manageVideos/Partials/add.component.ts (8,17):
Module '../../../../node_modules/tus-js-client/dist/tus.js'
was resolved to '/home/***/node_modules/tus-js-client/dist/tus.js',
but '--allowJs' is not set.
/home/***/src/app/manageVideos/Partials/add.component.ts (9,11): Cannot find name 'require'.
解决您问题的最简单方法是安装 TypeScript 声明:
npm install @types/tus-js-client --save-dev
并像这样导入它:
import * as tus from "tus-js-client";