我无法弄清如何使我的“tsc”命令工作:
tsc
module.js:472
throw err;
^
Error: Cannot find module 'typescript/tsc.js'
at Function.Module._resolveFilename (module.js:470:15)
我的 'package.json' 文件包含:
"devDependencies": {
"@types/node": "^14.11.2",
"tslib": "^2.0.1",
"typedoc": "^0.19.2",
"typescript": "^4.0.3"
}
我的 'tsconfig.json':
{
"compilerOptions": {
"target": "es6",
"sourceMap": true,
"declaration": true,
"declarationDir": "dist/types",
"strict": true,
"noUnusedLocals": true,
"lib": [
"es2019"
]
},
"include": [
"src"
]
}
'npm install'过程中没有任何错误。
当我检查'node_modules'文件夹时,发现 TypeScript 已经存在,并且 'tsc.js' 文件存在于 'typescript/lib' 目录下。
node 版本:12.18.4
npm 版本:6.14.6
系统环境:Ubuntu 16.04 LTS
我尝试了很多类似问题的解决方案,但都没有成功:
- 删除 node_modules 文件夹,再次运行 npm install
- 尝试手动重新安装:npm install typescript --save-dev
- 使用:npm install typescript-tools --save-dev
- ...
以上方法都无法解决问题。 非常感谢您的帮助。