我将 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 字样:
我注意到,如果我从控制台执行 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/