[英]error TS5023: Unknown compiler option 'p'
我在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 --version
來查看它是否是剛安裝的tsc的新版本,或者運行tsc --help
來幫助查看-p是否是受支持的選項,例如,我已經安裝了新版本2.5.2
,但是何時我運行tsc --version
,它總是報告1.0.3
它可能是由路徑沖突引起的,請從PATH環境中刪除Microsoft SDK中的tsc路徑,例如C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.0\\;
應該解決問題。
您可能正在運行與其他軟件包(例如Microsoft SDK )一起安裝的TypeScript的舊版本。 調出控制台並執行tsc
。 確保它是您期望的版本。 如果不是,那么您將需要更正path
環境變量以確保首先找到正確的版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.