我在 VS2015 社区更新 3 版本 14.0.25424.00 中创建了一个虚拟基本项目。 (使用这个很棒的教程:aspnet-core-web-api-angularjs-2)。
这个 angular-2 项目有一些 .ts 文件。
问题:
不是每次保存文件时都将其转译(“编译”)为 .js 文件,而是将 .ts 文件仅在构建时转译一次服务器端项目的。 (在 Visual Studio 中单击 F5)。
我用谷歌搜索了一下,发现我应该添加“watch”:true 到 tsconfig.json 文件:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "system",
"moduleResolution": "node",
"watch": true
},
"exclude": [
"node_modules",
"wwwroot/lib"
]
}
但是,现在我在构建时遇到错误: 错误“JsErrorScriptException (0x30001)”。 ASPNETCoreAngular2Demo C:\Visual Studio 2015\Projects\ASPNETCoreAngular2Demo\src\ASPNETCoreAngular2Demo\未知输出 1
根据this帖子中,VS2015 update 2中的解决方案是在tsconfig文件中添加:
"compileOnSave": true
但是,这在我的 update 3 版本中不起作用。
我从 cmd 运行以下命令:
>tsc -v Version 1.0.3.0
我认为它很旧,但我不知道如何更新它,因为正在运行:
>npm install -g typescript@* --save
未更改当前版本。
你有什么建议? 我很绝望..
TNX,
最佳答案
哇,可怜的微软..
这里的问题是,在安装 VS2015 时,我得到了 TypeScript 1.8, 但它没有更新Windows 10的PATH环境变量, 所以我实际上使用的是1.0版本。
我必须在 THIS POST 的帮助下手动更新它.
(请注意此处的注释,在 win10 操作系统上使用“compileOnSave”:true)。
现在开始工作了(-;
关于visual-studio - VS2015 : Adding "watch": true to tsconfig. json 导致 JsErrorScriptException (0x30001),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39021808/