Nathan Friend
Nathan Friend

Reputation: 12834

Visual Studio Code "Cannot compile modules unless the '--module' flag is provided" error

I'm using Visual Studio Code 0.10.6 to compile a TypeScript 1.8 (beta) project. The editor is showing a "Cannot compile modules unless the '--module' flag is provided" error:

Cannot compile modules unless the '--module' flag is provided

However, I have value for the module property in my tsconfig.json:

{
    "compilerOptions": {
        "target": "es5",
        "module": "system",
        "noImplicitReturns": true,
        "noImplicitAny": true,
        "noFallthroughCasesInSwitch": true,
        "preserveConstEnums": true,
        "sourceMap": true,
        "outDir": "./src/scripts/compiled",
        "rootDir": "./src/scripts"
    },
    "exclude": [
        "node_modules",
        "jspm_packages"
    ]
}

The project compiles without errors (I'm using gulp-typescript to compile my TypeScript files), and I've restarted the editor multiple times.

Why is Visual Studio Code showing this error, even though my code is compiling without errors?

Upvotes: 1

Views: 528

Answers (1)

aleung
aleung

Reputation: 10298

Visual Studio Code 0.10.6 hasn't build-in TypeScript 1.8 support yet.

Suppose you have install typescript 1.8 with npm install, add a line into .vscode/settings.json in your project to make use of it.

"typescript.tsdk": "./node_modules/typescript/lib"

Upvotes: 1

Related Questions