简体   繁体   English

Typescript tsc -w命令不监视文件更改

[英]Typescript tsc -w command not watching for file changes

I am currently trying to configure my application to watch for any file changes in Typescript and then recompile and restart the server when this happens. 我目前正在尝试将我的应用程序配置为监视Typescript中的任何文件更改,然后在发生这种情况时重新编译并重新启动服务器。 Here is my tsconfig.json: 这是我的tsconfig.json:

{
  "compilerOptions": {
    "target": "ES5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "rootDir" : "assets/app",
    "outDir": "../public/js/app"
  },
  "files": [
    "./assets/app/*"
  ],
  "exclude": [
    "node_modules"
  ],
  "atom": {
    "rewriteTsconfig": true
  }
}

As you can see, I have set the rootDir (where the .ts files are kept) and set the output directory (where there transpiled code is stored). 如您所见,我已经设置了rootDir(保存.ts文件的位置)并设置了输出目录(保存了已转码的代码的位置)。

Here is my file structure: 这是我的文件结构:

在此处输入图片说明

Now, when I try and run the tsc -w command I get the following error: 现在,当我尝试运行tsc -w命令时,出现以下错误:

error TS6053: File 'assets/app/*.ts' not found.

Which would indicate that the tsconfig.json file is not properly parsing my ts files from within the rootDir folder properly. 这表明tsconfig.json文件无法从rootDir文件夹中正确解析我的ts文件。 I have tried changing this but nothing seems to work. 我曾尝试更改此设置,但似乎无济于事。 Does anyone have any ideas? 有人有什么想法吗?

Thanks! 谢谢!

Not sure how it is with the atom editor, because they have some different settings, but as far as i know, you cannot use files with exclude . 不知道原子编辑器的情况如何,因为它们具有一些不同的设置,但是据我所知,您不能使用带有exclude files Because you already point to the rootDir , the files option is redundant, and should be removed 因为您已经指向rootDir ,所以files选项是多余的,应将其删除

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM