Node.js Typescript错误--错误:找不到模块';typescript/tsc.js';
我不知道如何使我的“tsc”命令工作:Node.js Typescript错误--错误:找不到模块';typescript/tsc.js';,node.js,typescript,module,tsc,Node.js,Typescript,Module,Tsc,我不知道如何使我的“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": "
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安装”期间没有错误
当我检查“node_modules”文件夹时,typescript存在,“tsc.js”文件存在于“typescript/lib”目录中
节点--版本:12.18.4
npm--版本:6.14.6
系统:Ubuntu 16.04 LTS
我尝试过针对类似问题提出的许多解决方案,但都没有成功:
- 删除node_modules文件夹,然后再次运行npm安装
- 尝试手动重新安装:npm安装类型脚本--保存开发
- 使用:npm安装类型脚本工具--保存开发
非常感谢您的帮助。对于那些陷入困境的人,您的本地tsc应该运行的命令是:
npx-tsc
要使tsc--version
命令正常工作,请尝试使用npm-install-g typescript
命令进行安装。它全局安装typescript