【问题标题】:TypeScript build error TS5023TypeScript 构建错误 TS5023
【发布时间】:2018-08-20 11:41:19
【问题描述】:

我正在尝试编译 TypeScript 和 NodeJS,遇到此错误有什么帮助吗?

tsc --version => 版本 2.7.2

error TS5023: Unknown compiler option 'lib'.
error TS5023: Unknown compiler option 'strict'.
error TS5023: Unknown compiler option 'esModuleInterop'.
The terminal process terminated with exit code: 1

更新,添加 tsconfig.json

{
  "compilerOptions": {
    "target": "ES5",                          
    "module": "commonjs",                    
    "lib": ["es2015"],                            

    "sourceMap": true,                     
    "strict": true,                           
    "esModuleInterop": true, 

    "mapRoot": "./map"                      
  }
}

【问题讨论】:

  • 你的 tsconfig.json 中有什么?
  • 更新问题
  • 在命令行上执行tsc 可能只会为您提供全局安装的版本。你的 local typescript 版本更新了吗?

标签: node.js typescript visual-studio-code


【解决方案1】:

为我解决的问题是通过 npm 包管理器安装全局打字稿:

npm install -g typescript

然后 tsc 编译器可用:

例如:tsc -p src/server/ -w

【讨论】:

    【解决方案2】:

    npm install --save-dev typescript@3.1.6 将其固定在我身边。

    【讨论】:

      【解决方案3】:

      我发现我的错误忘记调用本地版本的 TypeScript ./node_modules/.bin/tsc --init

      【讨论】:

      • call local version of TypeScript 是什么意思。你有例子吗?
      • 你的意思是你没有在项目中使用本地版本的 Typescript...?
      • 我有一个类似的问题,我使用 ntsc npm 包作为示例的一部分。更改为使用正确的 tsc 命令解决了我一半的问题。
      猜你喜欢
      • 2020-08-20
      • 1970-01-01
      • 1970-01-01
      • 2016-01-02
      • 2021-06-09
      • 2018-07-25
      • 2019-02-19
      • 1970-01-01
      • 2019-10-12
      相关资源
      最近更新 更多