Why npm install speed so slow? - node.js

i am using mac book pro - M1 chip and bigsur
but I have a problem.
the speed so slow when i install any library to npm
please click the picture i have counted
the picture, i had install the 'react-native-fast-image'
but there consumes more 1000s for installed
likewise,
i had typed in terminal, 'npm i or yarn install'
Consumes more than 30 minutes.
for solving this, i have tried deleted xcode, and webstrom, and vsc
but, there are no change in speed.

I had this exact same issue. After speaking with Genius Bar we realised I was on an old version 12 of node. Node 15.5 onwards runs natively on M1 so isn't being parsed through Rosetta 2, which was likely causing the lag.
You can check the version of node you're on by running node -v
If you're on anything below 15, if you run nvm install v15 on terminal this might solve your issue by updating your node.
I had an error at this point (you might not) saying:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools),
missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Which was solved with this.
After sorting that, when running nvm install v15 it solved the lagginess :) good luck!
You might also find even after installing the latest node, your terminal defaults to an old version (mine did to much bemusement!)
You can solve it be setting a default, check this link.
In short, run:
nvm use node
This switches to the latest installed version of node.

Today I used for the first time Node/NPM 17 and I got back to these issues of NPM install taking forever.
I switched back to Node/NPM 14 and everything works again just fine.

For those who cannot move their project to node 15 overnight.
Install node by itself by going on nodejs.org reduce drastically npm library installation on mac book pro - M1 Pro Monterey.

Related

NPM is really slow performing simple tasks

Everything I do with NPM takes several minutes; especially npm install, even if I already have all the packages installed. I first thought the problem is that the old code I am working with just takes longer to update (because last time an older npm version was used) but the problem percists even if I repeat the process.
My system and other Information:
Windows 11 PC
Ubuntu 18.04.5 VM from the Microsoft Store
VS Code.
npm version 8.19.2
node version 16.17.0
From my package-lock.json file: "lockfileVersion": 2
I usally have 5 to 10 dependecies listed in my package file
My internet speed is around 25 MB/s
What I tried so far with no luck:
A newer Version of Ubuntu
Using http instead of https a la:
npm config set registry http://registry.npmjs.org/ --global
as was suggested in 'npm install' extremely slow on Windows.
It seems to me it still tries to connect to the https address (at least that's what it looks like if I use npm install --verbose to show more feedback).
Reinstalling Node and NPM through other means as it was suggested in Why is "npm install" really slow?
No matter what I still sit here, wasting ages waiting for my npm install.
I finaly found a solution. I just did not now to ask the right question.
The problem was that I was using WSL version 2 and my files are in C: and not the Ubuntu folders. A fix that worked for me was moving to WSL version 1.
More details can be found here.
If you're also switching to WSL version 1 and are having problems with node or npm, this might help.

Nodejs with macOS: # Fatal error in , line 0 - gatsby develop

I am using gatsby cli, Suddenly gatsby develop command returning an error even if I create new site from scratch. I am using M1 macbook pro with big sur, is there anyone faced same issue? if yes how to resolve this?. I have configured everything properly by following official doc, am I missing something?
here is my terminal screenshot
Error:
macOS 11.2: Fatal error Check failed: allocator->SetPermissions
Parts of the stacktrace:
#
# Fatal error in , line 0
# Check failed: allocator->SetPermissions(reinterpret_cast<void*>(region.begin()), region.size(), PageAllocator::kNoAccess).
#
#
#
#FailureMessage Object: 0x16f986408
1: 0x100575758 node::NodePlatform::GetStackTracePrinter()::$_3::__invoke()
...
It seems a Node-related issue. According to this GitHub thread, try:
arch -x86_64 zsh
nvm install 14
nvm alias default 14
exit
All the solutions are related to the Node version. Remember to clean your cache by running gatsby clean and removing the node_modules in each trial.
As other threads points the issue seems to be related to the latest Node version. With the snippet above you'll roll back to version 14 as a temporal workaround while the issue is being fixed.
This was fixed in Node v15.9.0 If you installled using homebrew on a mac you can do brew upgrade node to get the latest version
Unfortunately the only solution is to revert to nodejs 14, using Rosetta.
Additional here's the issue in V8: https://bugs.chromium.org/p/v8/issues/detail?id=11389
No ETA. Everyone, please stop asking for when this will be resolved.
We know about the issue and are working on it.
Also note that Node.js is still not officially supported on
macOS+arm64. We do not produce binaries for it and you can use the x64
ones in the mean time.
https://github.com/nodejs/node/issues/37061#issuecomment-772559363
I fixed this issue by reinstalling node via nvm.
I had to open Rosetta 2 Terminal first.
nvm install node
nvm use node
After these commands.
I reinstalled packages using yarn command.
this way it worked.
This works... nvm install 16
Here's the nvm install docs... https://github.com/nvm-sh/nvm

Cannot install node.js under Windows 7: "the specified path is too long"

Using the newest node.js installer from https://nodejs.org, I run into the same error every time when it reaches the npm installation. npm 3.x was supposed to deal with this issue, but apparently it doesn't help the node.js installer. The node developers have essentially refused to do anything about it, as this problem has been around for about two years already. Unfortunately, I can't seem to find a work around. How can I get this to install?
I also had this error, trying to install node-v8.10.0-x64.msi on Windows 10.
My solution (to getting it to install; no idea if it won't break further down the line) was changing the install directory from C:/Program Files/nodejs to C:/njs/ (2nd step of current setup process).
I'm surprised those characters made the difference, and that there even is a Windows node release if there's not a proper solution to this (can't believe that maximum path length on Windows isn't modifiable), but this has seemingly worked for me.
I don't think its an installer error, actually windows is restricting the path size to be 150 char.
try reducing the file path name by copying it into direct c or d drive.
Check the link below Microsoft Forum
I've used Choco
It works together with NVM 4 Win.
After once installing node with choco install nodejs
then I install other versions of node using NVM e.g. nvm install 6.9.0
following by choosing that version with nvm use 6.9.0
and then verify with nvm list
and node -v.
I also need to install the latest version installed by choco using nvm install 10.1.0

Can't update from Node v0.10.46 on Mac

I'm having problem's when trying to run my gulp command in the terminal. I've been trying to track down the issue and from what I can tell the issue is that I'm running an outdated version of node.
node -v tells me that I am on v0.10.46, but the Node install downloaded from the website says it's currently on v4.4.7.
The first issue I had was with es6 promises, but I managed to install the es6-polyfill which solved the issue.
Now gulp is throwing an error related to /node_modules/gulp-imagemin/index.js. Specifically the use of const variables. (const path = require('path')).
Based on this thread: https://github.com/sindresorhus/gulp-imagemin/issues/181#issuecomment-219303510 - this issue seems to be an outdated version of node, but no matter what I do it won't upgrade!
I've explored all possible avenues for upgrading Node - using npm, nvm, n, brew and even a local re-install, but everytime it seems to be installing an outdated version.
I've explored the possibility that I'm installing a 32bit version on a 64bit system, but that doesn't seem to be the issue either.
I have absolutely no idea how to progress fixing this issue. I'm trying to build a wordpress website, and no matter what theme I use this error comes back to haunt me!
Help!
EDIT:
Just to add.. in this image (http://imgur.com/a/OzR5Y) you can see the output of me trying to upgrade using N, and then following the David Walsh upgrading method.
I had the same problem and I tried everything from uninstalling it by this instructions without any result. But maybe you have in your computer a management like nvm installed, just try this:
which node
And then if the respond of that is something like:
/Users/MYUSER/.nvm/v0.10.46/bin/node
That's the problem, so you can solve this by uninstalling nvm and then install Node.js normally or just keep using nvm

socket.io installation with npm

I installed Python 2.7 (had 3.4) and solved one error. Then, I installed Windows 7 SDK, solved another error, but no luck... I read here that I don't have to install Visual Studio as well... Can someone enlighten me with a solution?
The screenshots:
Assure this runs clean prior to your above install
npm install -g node-gyp
Do you have a c compiler installed ?
Are you creating a new nodejs app ? If so then issue this which will prompt you for details then cut a fresh package.json file for you :
npm init
In my opinion Windows is not the best for development , I have so much problems using Windows (and had the same problem), later I've switched to Ubuntu (just learn more Linux and C) - it has so much built-in programs so you don't have to install it by yourself (and you won't have any problems with that little problems and get even more knowledge).

Resources