node_modules/@types/node/index.d.ts(20,1): error TS1084: Invalid 'reference' directive syntax

heyJoe picture heyJoe · Sep 3, 2020 · Viewed 18.4k times · Source

I have a problem with typescript compilation. Have smbd faced with it?

node_modules/@types/node/index.d.ts(20,1): error TS1084: Invalid 'reference' directive syntax.

tsconfig.json:

{
    "compileOnSave": false,
    "compilerOptions": {
        "sourceMap": true,
        "outDir": "./dist",
        "rootDir": "./app",
        "target": "es6",
        "module": "commonjs",
        "declaration": false,
        "noImplicitAny": false,
        "removeComments": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "listFiles": false,
        "skipLibCheck": true
    },
    "include": [
        "./app/**/*.ts"
    ]
}

typescript version in package.json: "typescript": "^2.6.1"

Answer

Morfing picture Morfing · Sep 20, 2020

Had the same issue. Open the file ../node_modules/@types/node/index.d.ts

and remove the third slash

// <reference lib="es2015" />

compile again