【发布时间】:2017-05-03 20:22:00
【问题描述】:
我下载了一个 github 项目,我想在装有 Visual Studio 2015 Update 3 的机器上的 ASP.NET Core 项目中学习 TypeScript 和 Angular 2。
安装Microsoft.TypeScript.MSBuild 1.8.11 nuget 包后,我可以初步编译我的项目。但是,它失败,无法加载缺少 node_modules 包的 404 浏览器控制台错误。我的解决方案中不存在此文件夹。
我注意到systemjs.config.js 文件引用了 npm 和 node_modules。
/**
* System configuration for Angular samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': '/node_modules/',
'tether': '/Scripts/lib/tether.js'
},
// 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',
'@ng-bootstrap/ng-bootstrap': 'npm:/@ng-bootstrap/ng-bootstrap/bundles/ng-bootstrap.js',
// other libraries
'ng-lightning/ng-lightning': 'npm:ng-lightning/bundles/ng-lightning.umd.js',
'primeng': 'npm:primeng',
'lodash': 'npm:lodash',
'rxjs': 'npm:rxjs'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
primeng: {
defaultExtension: 'js'
},
'ng-lightning': {
defaultExtension: 'js'
},
lodash: {
main: 'index.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
然而 github 项目没有 node、gulp、bower 或 npm 来让 node 工作。 我知道如果你创建一个默认的 Visual Studio 2015 ASP.NET Core 应用程序,它会默认添加工作节点,但是如何将它节点到原始 github 作者似乎没有签入的现有项目。
我的 tsconfig.json 文件也无法编译
{
"compileOnSave": true,
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"typeRoots": [
"node_modules/@types"
],
"types": [
"core-js"
]
}
}
我明白了
构建:未知的编译器选项“类型”.VSTSC
构建:未知的编译器选项“typeRoots”。 VSTSC
【问题讨论】:
-
不是答案,但您可能还应该看看微软的 JavaScript Services 存储库。这为 asp.net 核心的官方 SPA 模板提供支持,例如 angular-2 template。
标签: angular visual-studio-2015 asp.net-core