安装无依赖项的npm软件包 [英] Install npm package without dependencies

查看:119
本文介绍了安装无依赖项的npm软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找最好的解决方案,如何安装npm软件包,而没有package.json文件中描述的依赖项.

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.

推荐答案

下面是一个shell脚本,它似乎为您提供了所需的提取文件.

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}"

将其另存为npm_download.sh,并使用所需包的名称运行它:

Save it as npm_download.sh and run it with the name of the package you want:

./npm_download.sh pathval

这篇关于安装无依赖项的npm软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆