如何在没有本地依赖的情况下收缩包装 npm 模块 [英] How to shrinkwrap npm modules without local dependencies

查看:78
本文介绍了如何在没有本地依赖的情况下收缩包装 npm 模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用节点模块依赖项列表来维护 package.json.当我调用 npm install 时,它会安装节点模块.并在我的应用程序中为它生成一个文件夹.我称之为 npm 收缩包装.但这会产生对本地节点模块的依赖

I tried to maintain package.json with the list of node modules dependencies. when I call npm install it installs the node modules.and generates a folder for it in my app. I call the npm shrinkwrap. But this generates the dependency on the local node module

  "dependencies": {
"async": {
  "version": "0.2.5",
  "from": "async@0.2.5",
  "resolved": "https://registry.npmjs.org/async/-/async-0.2.5.tgz"
},

当我将应用上传到 appfog 服务器时,它可以从 npm-shrinkwrap.json 安装.所以理想情况下,我想删除节点模块文件夹并传递shrinkwrap.json 文件.但它有这个来自".我过去曾生成过收缩包装 &它那里没有来自"字段.如何在没有from"的情况下生成/我可以从 package.json 中获取一个shrinkwrap 文件.所以我的应用程序会更精简.我可以全局维护所有节点模块.

when I upload the app to the appfog server it can install from the npm-shrinkwrap.json. So Ideally I want to remove the node modules folder and just pass the shrinkwrap.json file. But it has this "from". I had in the past generated the shrinkwrap & it didn't have the "from" field in there. How to generate without "from"/ can I just get a shrinkwrap file from package.json. so my app will be leaner. I can maintain all the node module globally.

谢谢

推荐答案

我对你的问题有点困惑.

I'm a bit confused by your question.

Shrinkwrap 不会安装、打包、上传或对您的依赖项执行任何操作.

Shrinkwrap does not install, package, upload or do anything to your dependencies.

它所做的只是扫描您安装的 node_modules 并将版本(递归地)记录到一个文件中.在定义该文件后调用 npm install 变得可重复,这是一个 软件工程原理.

All it does is scan your installed node_modules and record the versions (recursively) into a file. Invoking npm install after that file is defined becomes repeatable, which is a principle of software engineering.

from"是几个月前引入的.npm shrinkwrap 命令似乎将其设置为安装模块的 URL.这可能是为了便携性.npm install 获取模块名称,查询注册表(其 URL 可配置为 npm config 设置)并安装它.我可以使用相同的 package.jsonnpm-shrinkwrap.json,将它们放在另一台机器上,如果那台机器的 npm 配置,理论上会得到不同的结果代码> 设置将其指向不同的注册表.因此,在shrinkwrap 文件中嵌入解析的URL 为npm install

"from" was introduced a few months back. The npm shrinkwrap command seems to set it to the URL from which a module was installed. This is probably for portability. npm install takes a module name, consults a registry (whose URL is configurable as an npm config setting) and installs it. I could take the same package.json and npm-shrinkwrap.json, put them on another machine and theoretically get a different result if that machine's npm config settings point it to a different registry. Therefore, embedding the resolved URL in the shrinkwrap file adds an additional level of repeatability to npm install

有关设置注册表参数的详细信息,请参阅 npm 配置手册页.

See the npm config man page for details of setting the registry parameters.

根据 github 上的 npm 问题 3145,已知from"设置会导致向后兼容 1.2.x 之前的 npm 系统.升级是唯一的解决办法.

According to npm issue 3145 on github, the "from" setting is known to cause backwards-compatibility issues with pre-1.2.x npm systems. Upgrading is the only resolution.

https://github.com/isaacs/npm/issues/3145

这篇关于如何在没有本地依赖的情况下收缩包装 npm 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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