Install npm package without dependencies

北城余情 提交于 2019-12-01 00:53:43

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!