简体   繁体   English

错误TS5023:未知的编译器选项'p'

[英]error TS5023: Unknown compiler option 'p'

I am facing this issue while running the task in Visual studio code. 我在Visual Studio代码中运行任务时遇到此问题。 Here is the screen shot for reference. 这是供参考的屏幕截图。

在此处输入图片说明

here is the code for tasks.json 这是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"
}

and code for tsconfig.json 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
}

and code for systemjs.config.js 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);

Please help me in resolving this issue i have no idea what i did wrong. 请帮助我解决这个问题,我不知道我做错了什么。

seairth is correct, 没错,

you can run tsc --version to see if it is the new version of tsc you just installed, or tsc --help to see if -p is the supported option, eg I've installed a new version 2.5.2 , but when I run tsc --version , it always report 1.0.3 您可以运行tsc --version来查看它是否是刚安装的tsc的新版本,或者运行tsc --help来帮助查看-p是否是受支持的选项,例如,我已经安装了新版本2.5.2 ,但是何时我运行tsc --version ,它总是报告1.0.3

it should be caused by path conflicting, delete the tsc path in Microsoft SDK from PATH environment, eg C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.0\\; 它可能是由路径冲突引起的,请从PATH环境中删除Microsoft SDK中的tsc路径,例如C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.0\\; should solve the problem. 应该解决问题。

You may be running an older version of TypeScript that was installed with another package, such as the Microsoft SDK . 您可能正在运行与其他软件包(例如Microsoft SDK )一起安装的TypeScript的旧版本。 Bring up a console and execute tsc . 调出控制台并执行tsc Make sure it is the version you are expecting it to be. 确保它是您期望的版本。 If not, then you will need to correct your path environment variable to ensure that the correct version is found first. 如果不是,那么您将需要更正path环境变量以确保首先找到正确的版本。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM