【发布时间】:2016-03-03 01:06:52
【问题描述】:
【问题讨论】:
标签: javascript node.js typescript gulp visual-studio-code
【问题讨论】:
标签: javascript node.js typescript gulp visual-studio-code
打开您的tsconfig.json 文件并确保您已设置module
{
"compilerOptions": {
"module": "commonjs"
}
}
模块的可能值列表是:
注意如果您已经设置了module,您可能需要通过命令托盘重新加载编辑器
另外值得注意的是--module 是指在引入tsconfig.json 之前的命令行参数,它被命名为module
【讨论】:
>Reloac Window 不能解决问题。其他文件没有这个。尝试重新启动 IDE 并重新启动计算机,但它仍然显示错误(仅在 VS 代码中,而不是编译输出,并且仅针对该文件)
我遇到了编译器输出未指示错误但 VS Code 指示错误的情况。
具有以下 tsconfig.json:
{
"compilerOptions": {
"target": "ES5",
"watch": true,
"module": "amd",
"removeComments": true,
"outDir": "."
},
"files": [
"Filter",
"util.ts"
]
}
编译器没有错误,可以同时编译 Filter.ts 和 util.ts 但因为 tsconfig.json 在 Filter 中没有 .ts 扩展名;打开 util.ts 时,它会将整个文件内容用红色下划线,并带有 “除非提供 '--module' 标志,否则无法编译模块”
通过在末尾添加.ts 来修复它。
更改 tsconfig.json 后我重新加载了 ctrl + p => >Reload Window
【讨论】: