【问题标题】:error TS5023: Unknown compiler option 'p'错误 TS5023:未知的编译器选项“p”
【发布时间】:2016-07-04 19:38:37
【问题描述】:

我在 Visual Studio 代码中运行任务时遇到了这个问题。这是屏幕截图供参考。

这是 tasks.json

的代码
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "tsc",
    "isShellCommand": true,
    "args": ["-p", "."],
    "showOutput": "always",
    "problemMatcher": "$tsc"
}

tsconfig.json

的代码
{
  "compilerOptions": {
    "noImplicitAny": true,
    "noEmitOnError": true,
    "sourceMap": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node"
  },
  "exclude": [
    "node_modules",
    "wwwroot",
    "typings"
  ],
  "compileOnSave": true
}

systemjs.config.js

的代码
/**
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
    // map tells the System loader where to look for things
    var map = {
        'app': 'app', // 'dist',
        '@angular': 'node_modules/@angular',
        'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
        'rxjs': 'node_modules/rxjs'
    };
    // packages tells the System loader how to load when no filename and/or no extension
    var packages = {
        'app': { main: 'main.js', defaultExtension: 'js' },
        'rxjs': { defaultExtension: 'js' },
        'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
    };
    var ngPackageNames = [
      'common',
      'compiler',
      'core',
      'http',
      'platform-browser',
      'platform-browser-dynamic',
      'router',
      'router-deprecated',
      'upgrade',
    ];
    // Individual files (~300 requests):
    function packIndex(pkgName) {
        packages['@angular/' + pkgName] = { main: 'index.js', defaultExtension: 'js' };
    }
    // Bundled (~40 requests):
    function packUmd(pkgName) {
        packages['@angular/' + pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
    };
    // Most environments should use UMD; some (Karma) need the individual index files
    var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
    // Add package entries for angular packages
    ngPackageNames.forEach(setPackageConfig);
    var config = {
        map: map,
        packages: packages
    }
    System.config(config);
})(this);

请帮我解决这个问题,我不知道我做错了什么。

【问题讨论】:

  • 您可以完全删除 tsc 任务,将文件留空。然后打开cmd 并从那里运行tsc
  • 我也有同样的问题,找到解决办法了吗?
  • 不,我从头开始创建整个东西

标签: angular visual-studio-code


【解决方案1】:

sairth 是正确的,

您可以运行tsc --version 来查看它是否是您刚刚安装的新版本的 tsc,或者运行tsc --help 来查看 -p 是否是受支持的选项,例如我已经安装了新版本2.5.2,但是当我运行tsc --version时,它总是报告1.0.3

应该是路径冲突造成的,将微软SDK中的tsc路径从PATH环境中删除,例如C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\; 应该可以解决问题。

【讨论】:

    【解决方案2】:

    您可能正在运行旧版本的 TypeScript,该版本与其他软件包一起安装,例如 Microsoft SDK。调出控制台并执行tsc。确保它是您期望的版本。如果没有,那么您需要更正您的 path 环境变量以确保首先找到正确的版本。

    【讨论】:

      猜你喜欢
      • 2021-06-09
      • 2018-07-25
      • 2019-02-19
      • 2011-09-09
      • 1970-01-01
      • 1970-01-01
      • 2021-12-29
      • 2018-05-27
      • 2021-07-14
      相关资源
      最近更新 更多