简体   繁体   English

TSConfig 未知编译器选项“lib”

[英]TSConfig Unknown compiler option 'lib'

I am taking over an old angular 1 project with typescript 1.8.10.我正在使用 typescript 1.8.10 接管一个旧的 angular 1 项目。

However I can't compile and it keeps throwing me this :但是我无法编译,它不断向我抛出这个:

Unknown compiler option 'lib'

if i comment out the "lib" line, then I will face a huge load of other errors such as如果我注释掉“lib”行,那么我将面临大量其他错误,例如

 Property 'X' does not exist on type 'Y'

this is a fairly huge old project and I only want it to run for 2 weeks, so re-coding it is not an option for me due to timeline.这是一个相当庞大的旧项目,我只希望它运行 2 周,因此由于时间安排,重新编码对我来说不是一个选择。

I have tried changing many versions of typescript, but the same issue shows for me, I also tried to build using --noImplicitUseStrict but it doesn't help.我曾尝试更改打字稿的许多版本,但同样的问题对我来说也是如此,我也尝试使用 --noImplicitUseStrict 进行构建,但没有帮助。

Here is my tsconfig.json and my package.json这是我的 tsconfig.json 和我的 package.json

tsconfig.json配置文件

{
  "compileOnSave": false,
  "compilerOptions": {
      "module": "commonjs",
      "target": "es5",
      "noImplicitUseStrict" : true,
      "lib": ["es2015", "dom"]
 },
  "exclude": [
      "bower_components",
      "node_modules",
      "typings"
  ]
}

{
  "name": "xxx",
  "version": "0.0.0",
  "dependencies": {
    "@types/jquery": "^3.3.29",
    "grunt": "^1.0.4",
    "grunt-cli": "^1.3.2",
    "gulp-awspublish": "^3.3.0",
    "gulp-s3-deploy": "^1.0.1",
    "moment": "^2.24.0",
    "npm": "^6.9.0",
    "socket.io-client": "^1.7.2"
  },
  "scripts": {
    "test": "gulp test"
  },
  "devDependencies": {
    "@angular/cli": "^7.3.3",
    "browser-sync": "^2.26.5",
    "browser-sync-spa": "~1.0.3",
    "chalk": "~1.1.1",
    "del": "~2.0.2",
    "eslint-plugin-angular": "~0.12.0",
    "estraverse": "~4.1.0",
    "gulp": "^3.9.1",
    "gulp-angular-templatecache": "~1.8.0",
    "gulp-autoprefixer": "~3.0.2",
    "gulp-awspublish": "^3.3.0",
    "gulp-cssnano": "~2.1.1",
    "gulp-eslint": "~1.0.0",
    "gulp-filter": "~3.0.1",
    "gulp-flatten": "~0.2.0",
    "gulp-htmlmin": "~1.3.0",
    "gulp-inject": "~3.0.0",
    "gulp-load-plugins": "~0.10.0",
    "gulp-protractor": "~2.1.0",
    "gulp-rename": "~1.2.2",
    "gulp-replace": "~0.5.4",
    "gulp-rev": "~6.0.1",
    "gulp-rev-replace": "~0.4.2",
    "gulp-s3-deploy": "^1.0.1",
    "gulp-sass": "~2.0.4",
    "gulp-size": "~2.0.0",
    "gulp-sourcemaps": "~1.6.0",
    "gulp-uglify": "~1.4.1",
    "gulp-useref": "^3.1.6",
    "gulp-util": "~3.0.6",
    "http-proxy-middleware": "^0.19.1",
    "karma": "~0.13.10",
    "karma-coverage": "~0.5.2",
    "karma-jasmine": "~0.3.6",
    "karma-ng-html2js-preprocessor": "~0.2.0",
    "karma-phantomjs-launcher": "~0.2.1",
    "karma-phantomjs-shim": "~1.2.0",
    "lodash": "~3.10.1",
    "main-bower-files": "^2.13.1",
    "ng-annotate-loader": "0.0.10",
    "phantomjs": "~1.9.18",
    "ts-loader": "~0.8.0",
    "tslint-loader": "~1.0.2",
    "typescript": "^1.8.10",
    "typings": "~0.7.9",
    "uglify-save-license": "~0.4.1",
    "webpack-stream": "~2.1.1",
    "wiredep": "~2.2.2"
  },
  "engines": {
    "node": ">=0.10.0"
  }
}

Please give me some advice on this.请给我一些这方面的建议。 I am building it using Gulp.我正在使用 Gulp 构建它。

In my case, I just forgot to npm install before npm build .就我而言,我只是在npm build之前忘记了npm install It might help someone.它可能会帮助某人。

lib is a TypeScript 2 feature, and as you mentioned you are using 1.8. lib 是 TypeScript 2 的功能,正如您提到的,您使用的是 1.8。 You could remove that lib from the tsconfig.json or Try upgrading to a newer typescript version.您可以从 tsconfig.json 中删除该库或尝试升级到更新的打字稿版本。

In my package.json, I'm using the following dev dependencies:在我的 package.json 中,我使用了以下开发依赖项:

"ts-loader": "^5.4.4",
"typescript": "^3.4.5",

However, you may find some of your typescript breaks if you upgrade.但是,如果升级,您可能会发现一些打字稿会中断。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用VS 2015的Angular 2应用程序的VSTS中的“未知编译器选项lib” - 'Unknown Compiler Option lib' in VSTS of Angular 2 Application using VS 2015 未知的编译器选项“noImplicitOverride” - Unknown compiler option 'noImplicitOverride' 未知的编译器选项'noStrictGenericChecks' - Unknown compiler option 'noStrictGenericChecks' Tsconfig Build:' - lib'选项的参数必须是:'es5' - Tsconfig Build:Argument for '--lib' option must be: 'es5' 错误 TS5023:未知的编译器选项“compilerOptions” - error TS5023: Unknown compiler option 'compilerOptions' 错误TS5023:未知的编译器选项'p' - error TS5023: Unknown compiler option 'p' angular 2提前编译中未知的编译器选项“ angularCompilerOptions” - Unknown compiler option 'angularCompilerOptions' in angular 2 ahead-of-time compilation 错误 TS5023:未知的编译器选项“strictTemplates” - error TS5023: Unknown compiler option 'strictTemplates' 错误TS5023:未知的编译器选项'enableIvy' - error TS5023: Unknown compiler option 'enableIvy' 未知的编译器选项'文件'启动./node_modules/.bin/ng-xi18n - Unknown compiler option 'files' launching ./node_modules/.bin/ng-xi18n
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM