我试图弄清楚如何将this库导入到我的角度2应用程序中。试图在我的角度2应用程序中使用此库
我已经尝试了很多东西,但似乎无法得到它的工作。下面是我的部分systemjs.config.js
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
.... // Removed to conserve space
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
'youtube-dl': 'npm:youtube-dl'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'angular-in-memory-web-api': {
main: './index.js',
defaultExtension: 'js'
},
'youtube-dl': {
main: './lib/youtube-dl.js',
defaultExtension: 'js'
}
}
这是我正在努力将其导入到我的video.service.ts
import * as youtubedl from 'youtube-dl';
我似乎总是导致这个错误
app/service/video.service.ts(2,28):错误TS2307:无法找到模块'youtube-dl'。
下面是我的package.json
{
...,
...,
...,
"dependencies": {
"@angular/common": "~2.0.1",
"@angular/compiler": "~2.0.1",
"@angular/core": "~2.0.1",
"@angular/forms": "~2.0.1",
"@angular/http": "~2.0.1",
"@angular/platform-browser": "~2.0.1",
"@angular/platform-browser-dynamic": "~2.0.1",
"@angular/router": "~3.0.1",
"@angular/upgrade": "~2.0.1",
"angular-in-memory-web-api": "~0.1.1",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.39",
"zone.js": "^0.6.25",
"bootstrap": "^4.0.0-alpha.2",
"font-awesome": "^4.6.1",
"youtube-dl": "1.11.1"
},
"devDependencies": {
"concurrently": "^3.0.0",
"electron": "1.4.2",
"typescript": "^2.0.3",
"typings":"^1.4.0"
}
}
没过NPM LS并没有看到[email protected]上市以及
不能导入它作为一个节点依赖?似乎你已经在使用它了。 – Makoto
它似乎没有工作,无论我尝试结果到这个错误。 app/service/video.service.ts(2,28):错误TS2307:无法找到模块'youtubedl'。 – kotsumu
您应该编辑您的问题并包含该信息。如果你不能使用那些值得注意的NPM。另外,包含你的package.json。 – Makoto