Matanya dayfani
Matanya dayfani

Reputation: 93

ng build works but ng build --prod gives an error

I am a student and very new in every part of Angular. I'm building a very simple site. When i do ng build it works but ng build --prod gives an error

I tried ng update @ angular / cli @ angular / core. I removed all the services That did not solve the problem.

These are the errors I get in angular cli

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)

In the picture you can see the changes in the package.json file from the beginning until now

enter image description here

Upvotes: 2

Views: 7660

Answers (1)

Matanya dayfani
Matanya dayfani

Reputation: 93

Okay, I found the source of the problem. I needed to solve the error in refreshing the page in Angular. So I found somewhere that I was recommended to use:

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

It turns out that after I removed it everything works properly.

Now I have left to find a better way to avoid the error by refreshing the page ... Anyway, this is a new question that has nothing to do with this issue. Thank you very much for all the help!!!

enter image description here

Upvotes: 1

Related Questions