typescript - 在 TypeScript 中接收到执行文件路径错误

标签 typescript webstorm tsc

我将 WebStorm 用于使用转译的 TypeScript 开发的 node.js 应用程序。每当我通过从 TypeScript 选项卡中选择“全部编译”来运行 tsconfig.json 时,我都会收到以下错误:

Error:Initialization error (typescript). Cannot read property 'getExecutingFilePath' of undefined.

但是,如果我一次执行一个文件,我会收到“服务未启动”。

这是 tsconfig.json 文件:

{
"compilerOptions": {
  "module": "commonjs",
  "target": "ES6",
  "moduleResolution": "node",
  "experimentalDecorators": true,
  "emitDecoratorMetadata": true,
  "types": ["reflect-metadata"],
  "lib": ["ES6"],
  "sourceMap": true,
  "inlineSources": true,
  "pretty": true,
  "outDir": "dist",
  "rootDir": "src",
  "noLib": false,
  "declaration": true
},
"compileOnSave": true,
"include": [
  "src/**/*"
],
"exclude": [
  "node_modules"
]
} 

另外,我注意到我在屏幕右下角看不到 TypeScript 字样:

enter image description here

我注意到,如果我从控制台执行 tsc --version,我将获得版本 2.0.2,而如果我 Preferences -> Languages & Frameworks -> TypeScript,我正在为 WebStorm 获取 2.6.2。如果我从命令行运行 tsc 它似乎可以工作,但不能从 WebStorm 中运行。这个问题的原因可能是什么?

最佳答案

I noticed that if I do a tsc --version from the console, I am getting Version 2.0.2, whereas, if I Preferences -> Languages & Frameworks -> TypeScript, I am getting 2.6.2 for WebStorm

您在全局安装了 TypeScript 2.0.2,2.6.2 是您的本地项目版本。默认情况下,WebStorm 使用安装在项目 node_modules 中的 TypeScript。

很可能,您的 WebStorm 版本不支持 TypeScript 2.6.x(此版本包括重大 API 更改,因此 tsserver 集成可能会停止工作)。请在 Preferences -> Languages & Frameworks -> TypeScript 中将 TypeScript 版本更改为 Bundled - 有帮助吗?

关于typescript - 在 TypeScript 中接收到执行文件路径错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47646471/

相关文章:

typescript - 如何从枚举中获取联合类型的字符串值?

webstorm - 仅由 Markdown 软包装

node.js - typescript: tsc 不是内部或外部命令,也不是可运行的程序 或批处理文件

javascript - 任何 JavaScript 代码都是有效的 TypeScript 代码吗?

javascript - 如何使用mockDOMSource来测试Cycle.js中的操作流?

php - 从搜索中排除文件夹,但不在项目列表中

css - 在 WebStorm 的单行注释 block 中添加空格

typescript - 静音/忽略来自 TypeScript tsc 的 TS2307 错误

typescript - 检索函数的返回类型而不调用该函数

html - 如何在Angular 6中将maxlength设置为输入类型编号?