我使用npm将包'angular2-web-worker'安装到我的项目中,但在尝试使用它时遇到404(未找到)错误。
的package.json:
"dependencies": {
"@angular/animations": "^4.2.3",
"@angular/common": "^4.2.3",
"@angular/compiler": "^4.2.3",
"@angular/compiler-cli": "^4.2.3",
"@angular/core": "^4.2.3",
"@angular/forms": "^4.2.3",
"@angular/http": "^4.2.3",
"@angular/platform-browser": "^4.2.3",
"@angular/platform-browser-dynamic": "^4.2.3",
"@angular/platform-server": "^4.2.3",
"@angular/router": "^4.2.3",
"@angular/upgrade": "^2.4.10",
"@types/jasmine": "^2.5.52",
"@types/lodash": "^4.14.66",
"@types/node": "^6.0.78",
"angular-2-local-storage": "^1.0.1",
"angular-in-memory-web-api": "^0.2.5",
"angular2-web-worker": "0.0.6",
"bootstrap": "^3.3.7",
"browserify": "^14.5.0",
"concurrently": "^3.4.0",
"core-js": "^2.4.1",
"gulp-load-plugins": "^1.5.0",
"jquery": "^3.2.1",
"lite-server": "^2.3.0",
"lodash": "^4.17.4",
"moment": "^2.18.1",
"ng2-bs3-modal": "^0.10.4",
"primeng": "^4.0.0-rc.3",
"reflect-metadata": "^0.1.10",
"rollup-plugin-node-resolve": "^2.1.1",
"rollup-plugin-uglify": "^1.0.2",
"rxjs": "5.0.1",
"shim": "^0.6.0",
"systemjs": "0.19.40",
"typescript": "^2.4.0",
"zingchart": "^2.6.0",
"zone.js": "0.7.2"
},
"devDependencies": {
"browserify": "^14.5.0",
"concurrently": "^3.1.0",
"del": "^2.2.2",
"gulp": "^3.9.1",
"gulp-gzip": "^1.4.0",
"gulp-load-plugins": "^1.3.0",
"gulp-rename": "^1.2.2",
"gulp-task-listing": "^1.0.1",
"gulp-util": "^3.0.7",
"lite-server": "^2.2.2",
"rollup": "^0.36.1",
"rollup-plugin-commonjs": "^5.0.4",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-uglify": "^1.0.1",
"typescript": "^2.0.10",
"@types/node": "^6.0.46",
"@types/jasmine": "^2.5.36",
"@types/selenium-webdriver": "2.53.33"
}
SYSTEN-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': 'dist/app',
'main': 'dist/app/main.js',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
'@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
'@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
'@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'ng2-bs3-modal': 'npm:ng2-bs3-modal',
'angular2-web-worker': 'npm:angular2-web-worker/dist',
'angular-2-local-storage': 'npm:angular-2-local-storage/dist',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'lodash': 'npm:lodash',
'primeng': 'npm:primeng',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
'app': { main: './main.js', defaultExtension: 'js' },
'angular-2-local-storage': { main: './index.js', defaultExtension: 'js' },
'angular2-datatable': { main: './index.js', defaultExtension: 'js' },
'api': { defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' },
'ng2-bs3-modal': { defaultExtension: 'js' },
'lodash': { main: 'index.js', defaultExtension: 'js' },
'primeng': { defaultExtension: 'js' }
}
});
我的服务内部:
import { WebWorkerService } from 'angular2-web-worker';
constructor(localStorage: LocalStorageService, private _webWorkerService: WebWorkerService){
}
我收到错误:(SystemJS)XHR错误(404 Not Found)loading http://localhost:8000/node_modules/angular2-web-worker/dist 我也尝试过: 从'angular2-web-worker / web-worker.service'导入{WebWorkerService}; 但它没有奏效。问题是什么? 提前谢谢。