Reputation: 3700
I am trying to import globally install gulp module, but I am getting error "cannot compile modules unless the '--module' flag is provided" in visual studio code.
Where to set this --module flag?
Upvotes: 2
Views: 2986
Reputation: 39320
I ran into a situation where the compiler output does not indicate an error but VS Code does.
Having the following tsconfig.json:
{
"compilerOptions": {
"target": "ES5",
"watch": true,
"module": "amd",
"removeComments": true,
"outDir": "."
},
"files": [
"Filter",
"util.ts"
]
}
The compiler had no errors and would compile both Filter.ts and util.ts but because the tsconfig.json did not have the .ts
extension in Filter; when opening util.ts it would underline the entire file contents in red with the "cannot compile modules unless the '--module' flag is provided"
Fixed it by adding the .ts
at the end.
After changing the tsconfig.json I reloaded ctrl + p => >Reload Window
Upvotes: 1
Reputation: 65033
Open up your tsconfig.json
file and make sure you have module
set
{
"compilerOptions": {
"module": "commonjs"
}
}
The list of possible values for module are:
NOTE if you already have module
set, you might need to reload the editor via the command pallet
Also of note --module
is in reference to the command-line argument prior to the introduction of tsconfig.json
where it is just named module
Upvotes: 5