ng build работает, но ng build --prod выдает ошибку - PullRequest
1 голос
/ 26 марта 2019

Я студент и очень новичок в каждой части Angular. Я строю очень простой сайт. Когда я делаю ng build, он работает, но ng build --prod выдает ошибку

Я попробовал ng update @ angular / cli @ angular / core. Я удалил все услуги Это не решило проблему.

Это ошибки, которые я получаю в угловых кли

ng build --prod
...
...
...

ERROR in : Error: Internal error: unknown identifier [{"filePath":"C:/Users/user/source/repos/Angular/matanyaDayfani/node_modules/@angular/common/common.d.ts","name":"LocationStrategy","members":[]}]
    at Object.importExpr$$1 [as importExpr] (C:\Users\user\source\repos\Angular\matanyaDayfani\node_modules\@angular\compiler\bundles\compiler.umd.js:24170:27)
    at tokenExpr (C:\Users\user\source\repos\Angular\matanyaDayfani\node_modules\@angular\compiler\bundles\compiler.umd.js:19863:43)
    at providerDef (C:\Users\user\source\repos\Angular\matanyaDayfani\node_modules\@angular\compiler\bundles\compiler.umd.js:19789:24)
    at C:\Users\user\source\repos\Angular\matanyaDayfani\node_modules\@angular\compiler\bundles\compiler.umd.js:19959:81
    at Array.map (<anonymous>)
    at NgModuleCompiler.compile (C:\Users\user\source\repos\Angular\matanyaDayfani\node_modules\@angular\compiler\bundles\compiler.umd.js:19959:48)
    at AotCompiler._compileModule (C:\Users\user\source\repos\Angular\matanyaDayfani\node_modules\@angular\compiler\bundles\compiler.umd.js:24115:36)
    at C:\Users\user\source\repos\Angular\matanyaDayfani\node_modules\@angular\compiler\bundles\compiler.umd.js:24034:70
    at Array.forEach (<anonymous>)
    at AotCompiler._compileImplFile (C:\Users\user\source\repos\Angular\matanyaDayfani\node_modules\@angular\compiler\bundles\compiler.umd.js:24034:23)
    at C:\Users\user\source\repos\Angular\matanyaDayfani\node_modules\@angular\compiler\bundles\compiler.umd.js:24024:74
    at Array.map (<anonymous>)
    at AotCompiler.emitAllImpls (C:\Users\user\source\repos\Angular\matanyaDayfani\node_modules\@angular\compiler\bundles\compiler.umd.js:24024:39)
    at AngularCompilerProgram.generateFilesForEmit (C:\Users\user\source\repos\Angular\matanyaDayfani\node_modules\@angular\compiler-cli\src\transformers\program.js:620:46)
    at AngularCompilerProgram._emitRender2 (C:\Users\user\source\repos\Angular\matanyaDayfani\node_modules\@angular\compiler-cli\src\transformers\program.js:266:47)
    at AngularCompilerProgram.emit (C:\Users\user\source\repos\Angular\matanyaDayfani\node_modules\@angular\compiler-cli\src\transformers\program.js:201:22)

На рисунке вы видите изменения в файле package.json с самого начала и до настоящего времени

enter image description here

1 Ответ

0 голосов
/ 27 марта 2019

Хорошо, я нашел источник проблемы.Мне нужно было исправить ошибку при обновлении страницы в Angular.Так что я нашел где-то, что мне порекомендовали использовать:

import { HashLocationStrategy, LocationStrategy } from '@ angular / common';

Оказывается, после того, как я удалил его, все работает правильно.

Теперь мне осталось найтилучший способ избежать ошибки путем обновления страницы ... Во всяком случае, это новый вопрос, который не имеет ничего общего с этой проблемой.Большое спасибо за помощь !!!

enter image description here

...