node.jsangularnpmwebpacknpm-update

Angular | Chunk asset optimisation


This question is a duplicate of 92% chunk asset optimization - webpack . But there was no satisfactory answer for this.

Actually, at local, I use ng serve or nmp start to start my service and it works fine. But at EC2 instance I need to compress my webpack, so I use ng build --aot --prod.

A week ago, everything was working fine but suddenly it started stuck at this line: 92% chunk asset optimization, I don't know what is going wrong.

That is below:

Your global Angular CLI version (6.0.3) is greater than your local
version (1.6.1). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
 11% building modules 10/14 modules 4 active ...src/assets/css/smartadmin-rtl.min.cssNode#moveTo was deprecated. Use Container#append.
 92% chunk asset optimization

The possible reason can be that I have developed and tested everything on npm-6.0.0 and I'm trying to deploy on npm-5.6.0.

But When I try to update it using npm i -g npm to update it shows:

/home/ubuntu/.npm-global/bin/npm -> /home/ubuntu/.npm-global/lib/node_modules/npm/bin/npm-cli.js
/home/ubuntu/.npm-global/bin/npx -> /home/ubuntu/.npm-global/lib/node_modules/npm/bin/npx-cli.js
/home/ubuntu/.npm-global/bin/update -> /home/ubuntu/.npm-global/lib/node_modules/update/bin/update.js
+ to@0.2.9
+ update@0.7.4
+ npm@6.1.0
updated 3 packages in 15.729s

and when I try to run sudo npm i -g npm to update it shows this:

npm ERR! code 1
npm ERR! Command failed: /usr/bin/git clone -g git://github.com/jonschlinkert/resolve-file.got /home/ubuntu/.npm/_cacache/tmp/git-clone-d9e6c8aa
npm ERR! /home/ubuntu/.npm/_cacache/tmp/git-clone-d9e6c8aa/.git: Permission denied
npm ERR! 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2018-05-24T14_22_49_199Z-debug.log

I tried searching these error but no help.

Or the other issue can be:

Now my service has started using WebSocket in Angular, which was not there a week ago.

Please help me resolve this.


Solution

  • I had to remove all the angular dependencies from my machine and reinstall using:

    sudo apt-get purge npm
    sudo apt-get purge node
    

    If above commands won't work then type: sudo apt-get autoremove

    sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node opt/local/include/node /opt/local/lib/node_modules
    sudo rm -rf /usr/local/lib/node*
    sudo rm -rf /usr/local/include/node*
    sudo rm -rf /usr/local/bin/node*Install NPM
    sudo apt-get install npm
    

    Install latest version of NODE

    sudo npm cache clean -f
    sudo npm install -g n
    sudo n stable
    

    Then install angular CLI using:

    sudo npm install -g @angular/cli
    

    And then run:

    npm build --prod
    

    And error got removed itself, things are working now.