Отсутствует ошибка компиляции TypeScrypt после обновления угловой 4.4 до 6 - PullRequest
0 голосов
/ 29 августа 2018

Я обновил 4,4 угловое приложение до углового 6.

У меня было несколько ошибок, но я их исправил, и теперь, когда я запускаю npm run start, в конце компиляции (около 92%) я получаю следующую ошибку:

ERROR in ./node_modules/ngx-lorem-ipsum/lib/ngx-lorem-ipsum.component.ts
Module build failed: Error: /application/node_modules/ngx-lorem-ipsum/lib/ngx-lorem-ipsum.component.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview).
    at AngularCompilerPlugin.getCompiledFile (/application/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:749:23)
    at plugin.done.then (/application/node_modules/@ngtools/webpack/src/loader.js:41:31)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Я искал, как решить это, и я прочитал это письмо:

"paths": {
  "@ngx-lorem-ipsum/": [ "./node_modules/ngx-lorem-ipsum/lib/" ],
},

в конце tsconfig.json Это должно быть исправлено. Но компиляция продолжает сбой с той же ошибкой.

Теперь tsconfig.json выглядит так:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ],
    "module": "es2015",
    "baseUrl": "./",
    "paths": {
      "@ngx-lorem-ipsum/": [ "./node_modules/ngx-lorem-ipsum/lib/" ],
    },
  }
}

Как решить проблему с отсутствующей ошибкой компиляции TypeScrypt?

  • Угловой CLI: 6.1.5
  • Узел: 8.9.4
  • ОС: darwin x64
  • Угловой: 6.1.4
  • ngx-lorem-ipsum: ^ 0.1.1

1 Ответ

0 голосов
/ 29 августа 2018

Наконец, благодаря комментарию Михаила Бурштейна, я решил это. Мне пришлось добавить каталоги библиотеки в tsconfig.json с тегом include.

Теперь tsconfig.json выглядит так:

{
  "compileOnSave": false,
  "include": [
    "src/**/*.ts",
    "node_modules/ngx-lorem-ipsum/**/*.ts"
    ],
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ],
    "module": "es2015",
    "baseUrl": "./",
    "paths": {
      "@ngx-lorem-ipsum/": [ "./node_modules/ngx-lorem-ipsum/lib/" ],
    },
  }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...