gpt4 book ai didi

node.js - typescript 错误——错误 : Cannot find module 'typescript/tsc.js'

转载 作者:行者123 更新时间:2023-12-04 17:24:56 31 4
gpt4 key购买 nike

我不知道如何让我的“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 --version: 6.14.6

系统:Ubuntu 16.04 LTS

我已经尝试过针对类似问题提出的许多解决方案,但均未成功:

  • 删除 node_modules 文件夹,然后再次运行 npm install
  • 尝试手动重新安装:npm install typescript --save-dev
  • 使用:npm install typescript-tools --save-dev
  • ...

以上都没有给我任何结果。非常感谢您的帮助。

最佳答案

对于那些受困于此的人,应该使用您的本地 tsc 运行的命令是:

npx tsc

关于node.js - typescript 错误——错误 : Cannot find module 'typescript/tsc.js' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64081087/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com