2
votes

Setting up the environment for the Angular 2 with typescript. npm lite run successfully, but after installing typescript and add script for the start, there is error

error TS18003: No inputs were found in config file 'D:/practical/ang1/tsconfig.json'. Specified 'include' paths were '["**/"]' and 'exclude' paths were '["../wwwroot/app","node_modules/"]'.

package.json

  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\"",
    "test": "echo \"Error: no test specified\" && exit 1",
    "lite": "lite-server",
    "tsc": "tsc",
    "tsc:w": "tsc -w"
  },

tsconfig.json

{
  "compilerOptions": {
    "lib": [ "es5", "dom" ],
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  }
}

How to fix it this error

note the first time "npm start" work fine, but after deleting and resetting up, causing above issue

2

2 Answers

0
votes

After doing some digging, I add this line in the tsconfig.json under compilerOptions.

"typeRoots" : ["../node_modules/@types/"]
0
votes

faisaljanjua offers a helpful piece to the puzzle.

"typeRoots" : ["../node_modules/@types/"]

but I also needed

    "types": [
      "node"
    ],

(Note that adding node to types can leak npm packages in as well, so be sure to exclude them.) and

      "baseUrl": "./*",
      "paths": {
          "@/*":["./*"]
      },

where ./ is the current folder your tsconfig file lives in.

Since I added node to types. I needed to add node_modules here since they are owned by npm which is a node tool under the hood.

  "exclude": [
    ".git",
    "bin",
    "build",
    "node_modules"
  ]