我正在尝试在Visual Studio 2015 asp.net core 1.1中设置angular 2,并且在构建时遇到此错误。
上图中的相关文件位于路由器文件夹中
这是我的package.json
{ "name": "sample", "version": "1.0.0", "description": "", "scripts": { "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ", "e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first", "lint": "tslint ./app/**/*.ts -t verbose", "lite": "lite-server", "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"", "test-once": "tsc && karma start karma.conf.js --single-run", "tsc": "tsc", "tsc:w": "tsc -w" }, "keywords": [], "author": "", "license": "MIT", "dependencies": { "@angular/common": "~2.4.0", "@angular/compiler": "~2.4.0", "@angular/core": "~2.4.0", "@angular/forms": "~2.4.0", "@angular/http": "~2.4.0", "@angular/platform-browser": "~2.4.0", "@angular/platform-browser-dynamic": "~2.4.0", "@angular/router": "^3.4.0", "@angular/material": "^2.0.0-beta.1", "@angular/upgrade": "^2.1.0", "angular-in-memory-web-api": "~0.2.4", "systemjs": "0.19.40", "core-js": "^2.4.1", "rxjs": "5.0.1", "zone.js": "^0.7.4" }, "devDependencies": { "concurrently": "^3.1.0", "lite-server": "^2.2.2", "typescript": "~2.0.10", "canonical-path": "0.0.2", "http-server": "^0.9.0", "tslint": "^3.15.1", "lodash": "^4.16.4", "jasmine-core": "~2.4.1", "karma": "^1.3.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~4.0.14", "rimraf": "^2.5.4", "@types/node": "^6.0.46", "@types/jasmine": "^2.5.36", "gulp": "^3.9.1", "gulp-clean": "^0.3.2", "gulp-concat": "^2.6.0", "gulp-rename": "^1.2.2", "gulp-tsc": "^1.2.0", "gulp-typescript": "^2.13.6", "gulp-uglify": "^2.0.0", "path": "^0.12.7" }, "repository": {} }
这是tsconfig.js
"compileOnSave": true, "compilerOptions": { "emitDecoratorMetadata": true, "experimentalDecorators": true, "module": "commonjs", "noEmitOnError": true, "noImplicitAny": true, "outDir": "wwwroot/scripts/", "removeComments": false, "sourceMap": true, "suppressImplicitAnyIndexErrors": true, "target": "es5", "lib": [ "es2015", "dom" ], "moduleResolution": "node", "types": [ "jasmine" ], "typeRoots": [ "node_modules/@types" ] }, "exclude": [ "node_modules", "typings/index", "typings/index.d.ts" ] }
systemconfig.js
(function (global) { System.config({ paths: { 'npm:': 'lib/' }, // map tells the System loader where to look for things map: { // our app is within the app folder app: 'scripts', // 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/material': 'npm:@angular/material/material.umd.js', 'rxjs': 'npm:rxjs' }, packages: { app: { main: './main.js', defaultExtension: 'js' }, rxjs: { defaultExtension: 'js' } } }); })(this);
我将gulp脚本复制到lib文件夹中。
我想念什么?
我遇到了同样的问题,这对我有用。
如果您查看VS 2015中的upgrade.d.ts文件,您会注意到import语句上有一个红色的“ @ angular / upgrade / static”字样
我在node-modules文件夹中搜索了此依赖关系,但它不存在。所以我通过运行以下命令安装了它
在nangle / upgrade上运行npm
安装后,错误消失了。
我希望这有帮助。
最好的祝福,