I am looking for best solution how to install npm package without it's dependencies described in it's package.json file.
The goal is to change dependencies versions before install package. I can do it manually for one package by downloading source, but if you have many nested dependencies it becomes a problem.
Use npm ci to install all dependencies, including optional dependencies (e.g. on your development environment).
A dev dependency is a package used during development only. To remove a dev dependency, you need to attach the -D or --save-dev flag to the npm uninstall, and then specify the name of the package. You must run the command in the directory (folder) where the dependency is located.
The method described here is to package the dependencies into a tar file, then on the isolated environment, one can use the npm install <your tar file> command to install dependencies file without internet connection.
Here's a shell script that seems to get you the extracted files you need.
#!/bin/bash
package="$1"
version=$(npm show ${package} version)
archive="${package}-${version}.tgz"
curl --silent --remote-name \
"https://registry.npmjs.org/${package}/-/${archive}"
mkdir "${package}"
tar xzf "${archive}" --strip-components 1 -C "${package}"
rm "${archive}"
Save it as npm_download.sh
and run it with the name of the package you want:
./npm_download.sh pathval
Please check simialr quesition on stackexchange: https://unix.stackexchange.com/questions/168034/is-there-an-option-to-install-an-npm-package-without-dependencies
My solution was to rename package.json to package.bak before the install, then reverting rename afterwards:
RENAME package.json package.bak
npm install <package_name> --no-save
RENAME package.bak package.json
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