I'm more familiar with the Python ecosystem at this point and have a question about how I can do something with npm
that I'm used to doing with pip
.
Let's say I have a wheel for a particular Python package, as well as a wheel file for each of the Python package's dependencies. And let's say I have all these wheel files in a folder called /path/to/wheel/files
. To install this package and all of its dependencies, I could run something like pip install /path/to/wheel/files/*.whl --no-deps
, where --no-deps
keeps me from having to install the various dependencies in the proper order.
Does npm
have an equivalent to this? I'm using npm-offline-packager to create a tarball that contains a Node package (as its own tarball) and all of its dependencies (as their own tarballs). I know I can tell npm install
to install a particular tarball. However, when I do this, it tries pulling in the required dependencies from the online NPM registry instead of pulling in the dependencies from the tarballs I already have.
Ideally, I'd like npm install
to use the tarballs to add the main package to my project's package.json
while adding the package's dependencies to my project's package-lock.json
. And of course, I'd also like the main package and all its dependencies to be installed to my project's node_modules
directory as well.
TL;DR Does npm
have something equivalent to pip install /path/to/wheel/files/*.whl --no-deps
?
I'm responding to my own question here, but note that my answer is only applicable to my particular use case and may not be applicable in general.
For my use case, I have access to two computers: one that has access to the internet and one that doesn't. For the machine that doesn't have access to the internet, I was attempting to use Verdaccio as a way of creating a self-hosted NPM registry. However, publishing packages to Verdaccio wasn't working because it kept trying to pull in the package's dependencies from the public NPM repository. The solution was to remove all references to "npmjs" in Verdaccio's config file (which, for me, Verdaccio created at ~/.config/verdaccio/config.yaml
).
So, in case anyone needs to do development on a machine that doesn't have access to the internet, the process for setting up Verdaccio looks something like this:
npm init
(I called my project "verdaccio_runner"). The reason I did this is because, without already having an NPM registry on the machine that doesn't have access to the internet, it was hard doing a global install of Verdaccio.npm install verdaccio
to install Verdaccio to the NPM project that was created in the previous step.npx verdaccio
.~/.config/verdaccio/config.yaml
).npm config set registry http://localhost:4873/
.npm adduser
and by then filling out the information you're prompted for.And the process for publishing packages to Verdaccio on a machine that doesn't have access to the internet looks like this:
npo fetch <package name> --no-cache
(assuming you've already done a global install of npm-offline-packager on the machine that has internet access).npo
created for you over to the machine that doesn't have internet access.for file in ./*.tgz; do npm publish $file; done
.npm install
ed to projects on the machine that doesn't have internet access.Note: in order for Verdaccio to be accessible to other machines on the private network, I also had to add the following to Verdaccio's config file:
listen:
0.0.0.0:4873