I cloned some npm package from github and put the package in a local folder, e.g.
c:\git\package
I used "npm install -g" to install the package, which works really well.
npm install -g c:\git\package
However, when I did some change in the code of the package, e.g. checked out some branch. I couldn't use "npm update" to update the installed package. I have tried:
npm update -g
and
npm update -g packagename
or
npm update -g folderpath
Neither worked. I have to use "npm install" to reinstall it again for updating, which is wasting time to reinstall all dependencies.
Why does npm only support install from folder but not update from folder? If it does support, what shall I do? Thanks.
Use npm outdated to list the packages that are out of date with respect to what is installed in package.json Use npm update package_name to update an individual package that has already been installed. Use npm uninstall package_name and npm install package_name@version to revert to a specific version.
Since npm install <folder> adds the package in the directory as a symlink in the current project any changes to the local package are automatically synced. Anjum....
If no package name is specified, all packages in the specified location (global or local) will be updated. As of [email protected], the npm update will only inspect top-level packages. Prior versions of npm would also recursively inspect all dependencies. To get the old behavior, use npm --depth 9999 update.
Since private packages are always scoped, you must reference the scope name during installation: To confirm that npm install worked correctly, in your module directory, check that a node_modules directory exists and that it contains a directory for the package (s) you installed:
Instead of npm install
from a local directory, try npm link
, which creates a globally-installed symlink to the directory.
As stated in the docs, this is a two-step process:
In package directory:
$ npm link
This creates a symlink to the current folder in npm's global installation directory.
Somewhere else, where you want to use the module:
$ npm link <pkgname>
This will create a symlink in your project's node_modules/
folder to the global installation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With