node.js - 程序“tsc”未能运行:没有应用程序与此操作的指定文件关联
问题描述
下面是我在 package.json 中的 devDependencies
"@types/jasmine": "^3.6.2",
"@types/node": "^14.14.19",
"jasmine": "^3.6.3",
"protractor": "^7.0.0",
"typescript": "^4.1.3"
尝试运行时node_modules/typescript/bin/tsc Sample.ts
出现以下错误:
Program 'tsc' failed to run: No application is associated with the specified file for this operation line:1 char:1
+ node_modules/typescript/bin/tsc Sample.ts
我的系统路径变量
C:\Users\chinm\AppData\Roaming\npm
C:\Users\chinm\AppData\Local\Microsoft\TypeScript\4.0
解决方案
通常在文件顶部有一个 shebang 行
#!/usr/bin/env node
这指定了哪个程序应该运行脚本,但 Windows 操作系统不支持 shebang。因此,理想情况下,您不应使用此完整路径来运行tsc
. 让包管理器处理这个问题。
如果您使用 npm 安装了 tsc,请使用:
npx tsc Sample.ts
纱线用途:
yarn tsc Sample.ts
推荐阅读
- regex - Regex - match data between nth space and stop at nth space
- c++ - Why does the local variable in my thread function get interrupted by other threads?
- node.js - 从 cloudstar 生成的应用程序在 AWS cloud9 中快速运行 express 应用程序?
- c++ - C ++不合格名称查找:不同cpp中的不同结构大小导致运算符new分配的内存少于构造函数进程?
- java - 如何以编程方式获取所有相邻小区信息?
- android - SSL证书问题:Android Studio证书链中的自签名证书
- python - 如何创建 CSV 文件的标题?
- css - Wordpress 没有在移动设备上显示部分 CSS
- c - 将操作应用于 C 中的整个内存块
- python - 在 PyCharm 的远程解释器上运行远程脚本