How to update npm package from local folder

I cloned some npm package from github and put the package in a local folder, for example.

c:\git\package 

I used "npm install -g" to install the package, which works very well.

 npm install -gc:\git\package 

However, when I made some change in the package code, for example. checked some branch. I could not use "npm update" to update the installed package. I tried:

 npm update -g 

and

 npm update -g packagename 

or

 npm update -g folderpath 

None of them worked. I have to use "npm install" to reinstall it for the update, which takes time to reinstall all the dependencies.

Why does npm only support installation from a folder, but not updating from a folder? If he supports, what should I do? Thanks.

+6
source share
1 answer

Instead of npm install from the local directory, try npm link , which creates a globally installed symbolic link to the directory.

As stated in the docs , this is a two-step process:

  • In the package directory:

     $ npm link 

    This creates a symlink to the current folder in the npm global installation directory.

  • Somewhere else where you want to use the module:

     $ npm link <pkgname> 

    This will create a symlink in your node_modules/ folder for global installation.

+8
source

Source: https://habr.com/ru/post/947692/


All Articles