visual studio - VS2015:在 tsconfig.json 中添加 "watch": true 导致 JsErrorScriptException (0x30001)
我在 VS2015 Community Update 3,版本 14.0.25424.00 中创建了一个简单的示例项目。(使用这个很棒的教程:aspnet-core-web-api-angularjs-2)。
这个 angular-2 项目有一些 .ts 文件。
问题:
与其在每次保存文件时将 .ts 文件转译(“编译”)为 .js 文件,.ts 文件只在服务器端项目构建时(仅构建时)被转译一次。(从 Visual Studio 点击 F5)。
我在谷歌上搜索了一下,发现我应该在 tsconfig.json 文件中添加 "watch": true:
{
"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
根据这篇文章,VS2015 更新 2 中的解决方案是向 tsconfig 文件中添加:
"compileOnSave": true
然而,这在我的更新3版本中对我不起作用。
我在命令提示符下运行以下命令:
>tsc -v 版本 1.0.3.0
我觉得这个相当旧,但我不知道如何更新它,因为运行:
>npm install -g typescript@* --save
没有更改当前版本。
你建议什么?我很绝望..
谢谢,
答案#1
哇,可怜的微软..
这里的问题是,在安装 VS2015 时,我得到了 TypeScript 1.8,但它没有更新 Windows 10 的 PATH 环境变量,所以我实际上使用的是 1.0 版本。
我不得不在这篇文章的帮助下手动更新它。
(注意那里的评论,在 Windows 10 系统上使用 "compileOnSave": true)。
现在开始工作了 (-;