Missing *.ts files (due to `npm link` ?)

后端 未结 4 2274
梦毁少年i
梦毁少年i 2020-12-31 08:22

I have this import statement in an Angular5 project:

import {plugins, SCECodeGenType} from \'sce-plugins/code-generation\';

this resolves t

相关标签:
4条回答
  • 2020-12-31 08:34

    This can be caused by a case-sensitive typo in the url of an import.

    The 'stack trace' of the ng build output won't (or should I say might not) point you to the correct place. In my case, I did a global search in Visual Studio for the filename (excluding the .ts) and found a reference to the model definition file that was:

    import { ItemsUsedEntry } from '../models/itemsUsedentry.model';
    

    instead of

    import { ItemsUsedEntry } from '../models/itemsusedentry.model';
    

    This was easy to pick up in the Visual Studio global 'Find' window, by scanning all the results for my search on itemsusedentry.model.

    0 讨论(0)
  • 2020-12-31 08:37

    In Angular 6 "angular.json" file it's required to put "preserveSymlinks" under "options" Example:

    "defaults": {
            "build": {
              "builder": "@angular-devkit/build-angular:browser",
              "options": {
                "preserveSymlinks": true,
                "outputPath": "dist/ConsoleClient",
                "index": "src/index.html",
                "main": "src/main.ts",
                "polyfills": "src/polyfills.ts",
                "tsConfig": "src/tsconfig.app.json",
                "assets": [
                  "src/favicon.ico",
                  "src/assets",
                  "src/web.config"
                ],
    
    0 讨论(0)
  • 2020-12-31 08:46

    So after reading this Github issue again: https://github.com/angular/angular-cli/issues/8284

    I made this change in .angular-cli.json:

      "defaults": {
        "build": {
          "preserveSymlinks": true //   <<<< add this
        },
        "styleExt": "scss",
        "component": {
        }
      }
    

    and now, given that preserveSymlinks flag and the include field in my tsconfig.app.json file:

     "include":[
        "./**/*.ts",
        "../node_modules/sce-plugins/**/*.ts"
      ],
    

    I can now symlink 'sce-plugins' into my main project, instead of manually copying the files. It's possible that you won't need the "include" field at all, although I found that if I removed the "include" field, that it wouldn't work.

    0 讨论(0)
  • 2020-12-31 08:52

    I was having the same issue while migrating my app from Angular 5 to 6, fix I have applied:

    Added entry of missing file in includes array of tsconfig.app.json(ATTENTION: filename is not tsconfig.json)

    Also, make sure that the path you missing file you mention is relative to the tsconfig.app.json

    0 讨论(0)
提交回复
热议问题