Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm is really slow while installing/updating packages from private git repositories

I use a lot of private node packages (stored on my personal github repositories) in my projects:

"devDependencies": {
  ...
  "my-package": "github:username/my-package#master"
  ...
}

my issues is that, when updating a project or when running npm install, the process takes so long (~ 2 mins), while it's stuck doing something like:

reify:my-package: timing reify:loadBundles Completed in 0ms

Is there anything I can do to speed up the processes when using private repos?

Thanks

like image 648
Frank Avatar asked Mar 13 '21 08:03

Frank


People also ask

Why is npm install really slow?

Summary. DO NOT USE YOUR OS PACKAGE MANAGER TO INSTALL NODE. JS OR NPM - You will get very bad results as it seems no OS is keeping these packages (not even close to) current. If you find that npm is running slow and it isn't your computer or internet, it is most likely because of a severely outdated version.

How much time npm install takes?

The first application, lets refer to it as “EE”, runs in under 5 mins, while the other is taking over 10 mins to complete. It appears the problem is related to the npm install task.

Does npm install install devDependencies?

NPM installs devDependencies within the package. json file. The 'npm install' command should add all the dependencies and devDependencies automatically during installation. If you need to add specific devDependencies to your project, you can use this command- 'npm install --save-dev'.

How do I install a private GitHub repository using NPM?

A private GitHub repository can be installed using the git+ssh as protocol: Note: A GitHub package must have a meaningful package.json file to be installed as a package. The npm install command also provides many other features. For example, range can used to install a package with a given range for the version:

How to install a package using Git clone in NPM?

The npm command will try to install the package using git clone. The npm command can also install the package from different GitHub repository states using a commit hash value, which can be used to install the package with a commit id: 1 npm install use_name/node_project#commit

Why is my NPM install so slow?

And, with Windows, comes virus scanners, and virus scanning can make NPM install very slow! Adding an exemption or disabling virus scanning during install can greatly speed it up, but potentially this is undesirable given the possibility of malicious NPM packages Problem: NPM does not perform well if you do not keep it up to date.

Is there a faster way to install npm packages?

You could use Yarn as an alternative to install npm packages, it does provide faster installs. Sorry, something went wrong. Strange behavior in corporate network it's taking hours with HTTP:/registry but inside my home network it's taking hardly 5 minutes


1 Answers

This isn't a problem with Private repositories or GitHub, NPM itself has been very slow recently. You might want to go with a faster alternative like yarn, It's much faster and can save a ton of time.

Installation of Yarn

To install Yarn you just have to run npm install yarn -g. That will install yarn globally.

Commands of Yarn

This cheat sheet of Yarn alternatives to NPM commands can help - https://shift.infinite.red/npm-vs-yarn-cheat-sheet-8755b092e5cc

Hope it helped :)

like image 71
FrostyTheDumDum Avatar answered Oct 03 '22 06:10

FrostyTheDumDum