Angular | Chunk asset optimisation - node.js

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.

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.

Related

error Cannot find module 'semver' in (npm run dev) command

im using laravel 8 and vuejs to create my website
i have this error after run npm run dev command:
Error: Cannot find module 'semver'
Require stack:
- /usr/share/npm/lib/utils/unsupported.js
- /usr/share/npm/bin/npm-cli.js
...
id tried this solutions:
sudo apt-get purge nodejs --auto-remove
sudo apt-get purge npm --auto-remove
sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* ~/.npm
sudo rm -rf /usr/local/lib/node*
sudo rm -rf /usr/local/bin/node*
sudo rm -rf /usr/local/include/node*
sudo apt-get purge nodejs npm
sudo apt autoremove
npm i -g semver
and then installed again the nodejs and npm (latest version)
but the error still exist
what should i do
There are some modules missing in your /usr/share/npm.
So this will I guess solve the problem
cd /usr/share/npm; npm i
If this doesn't work then you can also just go on installing each missing module in /usr/share/npm.
just try to install npm globally , it will install latest version of npm
sudo npm install -g npm
it worked for me.
The error is basically saying you are missing the module, so you need to install it this way :
npm install semver

How to update NPM 6.13.4 to 7.16.0 on Mac?

I'm studying Laravel, and after I run the command npm run dev, I saw these messages:
New major version of npm available! 6.13.4 → 7.16.0
Changelog: https://github.com/npm/cli/releases/tag/v7.16.0
Run npm install -g npm to update!
But when I run the command: npm install -g npm on terminal, I get a lot of messages about permissions:
The command sudo chown -R 501:20 "/Users/myfolder/.npm" doesn't change anything. I tried to clear the cache with:
npm cache clean --force
Still nothing.
I don't know much about npm and I have this problem on my mac for a long time, since I can't find a way to solve this. I don't even know how to completely remove npm/node. So, I'm pretty stuck.
Can anyone please help me?
npm install -g npm#latest
Install latest version
Permission problem solve
sudo chown -R user:group folder
sudo chmod -R 755 folder
or
sudo npm install -g npm#latest

npm issue after update

After update npm i cannot use npm install when i run
npm install
i've got
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './lib/extract-stream.js'
The location of extract-stream.js is /usr/local/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js
If i run
/usr/local/bin/npm install # IT WORKS!
when i run
which npm
# output: {my_home_path}/.npm-global/bin/npm
and when i run
npm -v
# output: 6.7.0
/usr/local/bin/npm -v
# output 6.5.0
How can i fix this issue?
brew uninstall --force node
sudo rm -rf /usr/local/lib/node_modules
brew install npm
Worked just fine
First delete the file 'composer.lock.json' and run rm -rf node_modules to remove the node_modules folder. After this try to re-install npm with npm install.
Note: if you get this error node_modules/.bin/npm: No such file or directory. Run hash -r and after this npm install.

npm install settings to display dependencies being installed

when running npm install on any project I used to get a result looking like this https://prnt.sc/grns5z
which shows all the dependencies being installed,
I recently installed sudo npm install -g react#16.0.0-alpha.6 and npm install npm#latest -g
after running these two commands I no longer see the dependencies being installed in yellow text
This is what I see now
https://prnt.sc/grntzv
Is there a option or setting to display the dependencies being installed like in the first screenshot?
I tried resetting npm global settings with echo "" > $(npm config get globalconfig)
npm config --global edit but it didn't work,
Try killing any lingering node processes by running these codes:
sudo kill -9 ```pgrep node```
rm -rf ./node_modules
npm update
then you should try running the codes again.
*******:~$ sudo npm install -g react#16.0.0-alpha.6
It should show you this after it installs successfully
+ react#16.0.0-alpha.6
added 16 packages in 35.241s
and
*******:~$ sudo npm install npm#latest -g
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
+ npm#5.4.2
updated 1 package in 15.393s

Why is my npm not updating to 3.7.2 from 2.14.12?

I have installed node from node's website. By default I have got npm version 2.14.12. Now I want to update npm to 3. I am doing this -
$ npm -v
2.14.12
$ sudo npm install npm#latest -g
/Users/sudiptasen/.node/bin/npm -> /Users/sudiptasen/.node/lib/node_modules/npm/bin/npm-cli.js
npm#3.7.2 /Users/sudiptasen/.node/lib/node_modules/npm
$ npm -v
2.14.12
Even I have tried, sudo npm update npm -g, sudo npm install npm#3.7.2 -g but none of these working either.
What am I missing?
Now this may not work for you because I was already on npm 3.5.3, but try running:
npm install -g npm (with sudo in front if need be).
By running that I was able to update to 3.7.2.
I just had to create a symlink over my default npm.
sudo ln -s /Users/sudiptasen/.node/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm

Resources